In case anyone ends up here as well. As of today, if you are targeting Android-12+, you will still crash if you use Local (and remote?) Notifications, since Engine code has not been fully modified. I’ve attached a patch file and have submitted a bug to Epic. In the meantime, if you use Engine Source, you can use this patch. Actually, if use the off-the-shelf launcher Unreal, you should be able to patch these files as well. The following patch was applied to UE5.1, but similar changes can be done on UE4.26 and UE5.0.3
---
.../src/com/epicgames/unreal/GameActivity.java.template | 6 +++---
.../src/com/epicgames/unreal/LocalNotificationReceiver.java | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Engine/Build/Android/Java/src/com/epicgames/unreal/GameActivity.java.template b/Engine/Build/Android/Java/src/com/epicgames/unreal/GameActivity.java.template
index 6847fd729f84..e1d99143d455 100644
--- a/Engine/Build/Android/Java/src/com/epicgames/unreal/GameActivity.java.template
+++ b/Engine/Build/Android/Java/src/com/epicgames/unreal/GameActivity.java.template
@@ -5088,7 +5088,7 @@ public class GameActivity extends $${gameActivitySuperClass}$$ implements Surfac
notificationIntent.putExtra("local-notification-activationEvent", activationEvent);
// Designate the callback as a PendingIntent
- PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
TimeZone targetTimeZone = TimeZone.getTimeZone("UTC");
@@ -5158,7 +5158,7 @@ public class GameActivity extends $${gameActivitySuperClass}$$ implements Surfac
for(int curID : idList)
{
AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pendingIntent = PendingIntent.getBroadcast(this, curID, new Intent(this, LocalNotificationReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(this, curID, new Intent(this, LocalNotificationReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
pendingIntent.cancel();
alarmManager.cancel(pendingIntent);
}
@@ -5186,7 +5186,7 @@ public class GameActivity extends $${gameActivitySuperClass}$$ implements Surfac
//Cancel the intent itself as well as from the alarm manager
AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- PendingIntent pendingIntent = PendingIntent.getBroadcast(this, notificationId, new Intent(this, LocalNotificationReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(this, notificationId, new Intent(this, LocalNotificationReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
pendingIntent.cancel();
alarmManager.cancel(pendingIntent);
diff --git a/Engine/Build/Android/Java/src/com/epicgames/unreal/LocalNotificationReceiver.java b/Engine/Build/Android/Java/src/com/epicgames/unreal/LocalNotificationReceiver.java
index 285f7d0a81a5..5216372ca859 100644
--- a/Engine/Build/Android/Java/src/com/epicgames/unreal/LocalNotificationReceiver.java
+++ b/Engine/Build/Android/Java/src/com/epicgames/unreal/LocalNotificationReceiver.java
@@ -46,7 +46,7 @@ public class LocalNotificationReceiver extends BroadcastReceiver
notificationIntent.putExtra("localNotificationLaunchActivationEvent", activationEvent);
int notificationIconID = getNotificationIconID(context);
- PendingIntent pendingNotificationIntent = PendingIntent.getActivity(context, notificationID, notificationIntent, 0);
+ PendingIntent pendingNotificationIntent = PendingIntent.getActivity(context, notificationID, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
@SuppressWarnings("deprecation")
--