从数据库PhoneGap / Android恢复联系人

时间:2022-04-06 22:59:00

I am working on a small example Cordova/PhoneGap APP for Android. The Goal: Take a contact, save it to an external MySQL Database - Restore it from Database.

我正在开发一个用于Android的小型Cordova / PhoneGap APP示例。目标:联系,将其保存到外部MySQL数据库 - 从数据库中恢复。

$scope.pickContact = function() {
        ContactsService.pickContact().then(
            function(contact) {
                $scope.data = contact.clone();
                // post to db ... code removed
            },
            function(failure) {
                console.log(failure);
            }
        );
    }

It works well, with one exception: I have no clue of to restore the contact photo from DB. If I save the contact, it is saved with the URL to cropped profile picture:

它运作良好,但有一个例外:我不知道从DB恢复联系人照片。如果我保存了该联系人,则会将其与URL一起保存到裁剪的个人资料图片:

"content://com.android.contacts/contacts/18/photo"

This is also returned when fetching from DB, but when the contact was deleted - the photo is erased. Can I access the photo from Cordova and store/recreate it?

从DB获取时也会返回此选项,但删除联系人后 - 照片将被删除。我可以从Cordova访问照片并存储/重新创建吗?

1 个解决方案

#1


0  

Ok... seems to be an bug in Cordova Contacts Plugin. Regarding some documentation you can pass a base64 string like this:

好的......似乎是Cordova Contacts Plugin中的一个错误。关于某些文档,您可以传递base64字符串,如下所示:

theContact.photos[0] = new ContactField('base64', base64, true)

theContact.photos [0] = new ContactField('base64',base64,true)

But the function in contacts plugin, to resolve this does not support this format.

但是联系人插件中的功能,解决这个问题并不支持这种格式。

platforms/android/src/org/apache/cordova/contacts/ContactAccessorSdk5.java

/**
   * Get an input stream based on file path or uri content://, http://, file://
   *
   * @param path
   * @return an input stream
 * @throws IOException
   */
private InputStream getPathFromUri(String path) 

For a work a round: https://groups.google.com/forum/#!topic/phonegap/jTMu9Azjaa8

对于一轮工作:https://groups.google.com/forum/#!topic / phonegap / jTMu9Azjaa8

#1


0  

Ok... seems to be an bug in Cordova Contacts Plugin. Regarding some documentation you can pass a base64 string like this:

好的......似乎是Cordova Contacts Plugin中的一个错误。关于某些文档,您可以传递base64字符串,如下所示:

theContact.photos[0] = new ContactField('base64', base64, true)

theContact.photos [0] = new ContactField('base64',base64,true)

But the function in contacts plugin, to resolve this does not support this format.

但是联系人插件中的功能,解决这个问题并不支持这种格式。

platforms/android/src/org/apache/cordova/contacts/ContactAccessorSdk5.java

/**
   * Get an input stream based on file path or uri content://, http://, file://
   *
   * @param path
   * @return an input stream
 * @throws IOException
   */
private InputStream getPathFromUri(String path) 

For a work a round: https://groups.google.com/forum/#!topic/phonegap/jTMu9Azjaa8

对于一轮工作:https://groups.google.com/forum/#!topic / phonegap / jTMu9Azjaa8