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

Fixes Android 12 missing FLAG_IMMUTABLE #98

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public Notification getNotification(String title, String text, String largeIcon,
builder.setSmallIcon(android.R.drawable.ic_menu_mylocation);
}
if (largeIcon != null && !largeIcon.isEmpty()) {
builder.setLargeIcon(BitmapFactory.decodeResource(appContext.getResources(), mResolver.getDrawable(largeIcon)));
int largeIconId = mResolver.getDrawable(largeIcon);
if (largeIconId == 0) {
logger.warn("The resource " + largeIcon + " was not found in the drawable folder. Please include it when building the app.");
}
builder.setLargeIcon(BitmapFactory.decodeResource(appContext.getResources(), largeIconId));
}
if (color != null && !color.isEmpty()) {
builder.setColor(this.parseNotificationIconColor(color));
Expand All @@ -74,7 +78,10 @@ public Notification getNotification(String title, String text, String largeIcon,
if (launchIntent != null) {
// NOTICE: testing apps might not have registered launch intent
launchIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(appContext, 0, launchIntent, PendingIntent.FLAG_CANCEL_CURRENT);
int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
? PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE
: PendingIntent.FLAG_CANCEL_CURRENT;
PendingIntent contentIntent = PendingIntent.getActivity(appContext, 0, launchIntent, flags);
builder.setContentIntent(contentIntent);
}

Expand Down