0

I am using the following

- Cordova 3.7.0
- Android (21)
- local notification plugin
- grabbing contacts via contacts plugin

from the contacts I take the contact picture uri which looks like

content://com.android.contacts/contacts/2/photo

when I try to set the notification.icon to the uri the app crashes and no notification is shown.

Any idea how I need to reformat the uri to allow the local notification to work?

Best

Dinkheller
  • 4,631
  • 5
  • 39
  • 67

1 Answers1

0

I found a solution, which includes changing the actual plugin AssetUtil.java

Uri parse (String path) {

    if (path.startsWith("res:")) {
        return getUriForResourcePath(path);
    } else if (path.startsWith("file:///")) {
        return getUriFromPath(path);
    } else if (path.startsWith("file://")) {
        return getUriFromAsset(path);
    } else if (path.startsWith("http")){
        return getUriFromRemote(path);
    } else if (path.startsWith("content://")){ //<--- Add the following lines
        return getUriFromContact(path);
    }

    return Uri.EMPTY;
}

private Uri getUriFromContact(String path) {   //<--- Add this method
    Uri photoUri;
    photoUri = Uri.parse(path);

    return photoUri;
}
Dinkheller
  • 4,631
  • 5
  • 39
  • 67