From 23c1eae8b62d01cb858d93f2791dae0732acd11d Mon Sep 17 00:00:00 2001 From: Phil Hudson <1914950+phil-hudson@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:52:57 +0800 Subject: [PATCH] fix(android): set pending intent flag to stop insta-crash fix(android): add conditional check for minimum sdk version fix(android): formatting fix(android): formatting fix(android): formatting fix(android): formatting again (cherry picked from commit ce7f648694300a34747c5bab665f7d7f5e51ff61) --- .../java/lib/src/org/godotengine/godot/Godot.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 9b65a52b70d..9902efbdf29 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -685,8 +685,14 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC Intent notifierIntent = new Intent(activity, activity.getClass()); notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); - PendingIntent pendingIntent = PendingIntent.getActivity(activity, 0, - notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + pendingIntent = PendingIntent.getActivity(activity, 0, + notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); + } else { + pendingIntent = PendingIntent.getActivity(activity, 0, + notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT); + } int startResult; try {