Fixed notification large bitmap icon

This commit is contained in:
M66B 2018-12-10 12:37:37 +01:00
parent bd58041ab1
commit 0680b842d5
1 changed files with 13 additions and 7 deletions

View File

@ -639,20 +639,26 @@ public class ServiceSynchronize extends LifecycleService {
try {
cursor = getContentResolver().query(
Uri.parse(message.avatar),
new String[]{ContactsContract.Contacts._ID},
new String[]{
ContactsContract.Contacts._ID,
ContactsContract.Contacts.LOOKUP_KEY
},
null, null, null);
if (cursor.moveToNext()) {
Uri photo = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI,
cursor.getLong(0) + "/photo");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
Uri uri = ContactsContract.Contacts.getLookupUri(
cursor.getLong(0), cursor.getString(1));
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(
getContentResolver(), photo);
getContentResolver(), uri);
mbuilder.setLargeIcon(BitmapFactory.decodeStream(is));
} else
} else {
Uri photo = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI,
cursor.getLong(0) + "/photo");
mbuilder.setLargeIcon(Icon.createWithContentUri(photo));
}
}
} catch (SecurityException ex) {
} catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
} finally {
if (cursor != null)