Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Commit

Permalink
add PendingIntent.FLAG_IMMUTABLE for Android 12
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmaeuer committed Nov 23, 2021
1 parent 8edd66c commit b14e006
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ public synchronized Notification prepareNotification(NotificationCompat.Builder
String packageName = context.getPackageName();
Intent openApp = context.getPackageManager().getLaunchIntentForPackage(packageName);
try {
builder.setContentIntent(PendingIntent.getActivity(context, 0, openApp, 0));
builder.setContentIntent(PendingIntent.getActivity(context, 0, openApp, PendingIntent.FLAG_IMMUTABLE));
}catch(Exception e){
System.out.println(e.getMessage());
}

// Remove notification
Intent remove = new Intent(REMOVE_NOTIFICATION);
remove.putExtra(PACKAGE_NAME, context.getApplicationInfo().packageName);
builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, remove, PendingIntent.FLAG_UPDATE_CURRENT));
builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, remove, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT));

return builder.build();
}
Expand Down Expand Up @@ -176,7 +176,7 @@ private NotificationCompat.Action createAction(String iconName, String title, lo
Intent intent = new Intent(MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
intent.putExtra(PACKAGE_NAME, packageName);
PendingIntent i = PendingIntent.getBroadcast(context, keyCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent i = PendingIntent.getBroadcast(context, keyCode, intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);

return new NotificationCompat.Action(icon, title, i);
}
Expand Down

0 comments on commit b14e006

Please sign in to comment.