Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications Error Android 11 #297

Closed
mastermichi opened this issue Nov 1, 2021 · 2 comments
Closed

Notifications Error Android 11 #297

mastermichi opened this issue Nov 1, 2021 · 2 comments

Comments

@mastermichi
Copy link
Contributor

"Notifications in Night Clock don't display the correct icon, instead of showing whatever icon appears in the actual notification it just shows an i in a circle icon. In the attached screenshot the notification was for Gmail which has an envelope icon."

Screenshot_20211012-174700

Seems to be a problem with "Alerting notifications" (German: "Erinnerungsbenachrichtigung")
-> No Problem with Android 9

@firebirdberlin
Copy link
Owner

Probably we have to switch to another method to retrieve the drawables. The current code is quite old. We could use api level M yet. Nowadays almost everybody has at least M.

@RequiresApi(api = Build.VERSION_CODES.M)
private Drawable getSmallIcon(Context context, StatusBarNotification sbn) {
    Notification notification = sbn.getNotification();
    Icon icon = notification.getSmallIcon();
    return icon.loadDrawable(context);
}

@mastermichi mastermichi changed the title "Alerting notifications" Notifications Error Android 11 Nov 2, 2021
@mastermichi
Copy link
Contributor Author

mastermichi commented Nov 2, 2021

Error: android.content.pm.PackageManager$NameNotFoundException
More informations: https://stackoverflow.com/questions/62345805/namenotfoundexception-when-calling-getpackageinfo-on-android-11
Permission "QUERY_ALL_PACKAGES" needed: https://support.google.com/googleplay/android-developer/answer/10158779?hl=de
https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9

We also have to find a solution for "BrowseNotificationApps":
try {
ai = pm.getApplicationInfo(app.getPackageName(), 0);
if (ai != null) {
holder.appicon.setImageDrawable(pm.getApplicationIcon(ai));
}
} catch (PackageManager.NameNotFoundException ex) {
Log.e(TAG, "Appicon not found. ", ex);
holder.appicon.setImageResource(R.mipmap.ic_launcher);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants