From e9299d0ce74ce539290ed1764114e7a007358d04 Mon Sep 17 00:00:00 2001 From: David Domingues <49404822+d-domingues@users.noreply.github.com> Date: Tue, 13 Dec 2022 20:50:38 +0100 Subject: [PATCH] fix(api 31): fixed issue that crashes the app --- src/android/nl/xservices/plugins/SocialSharing.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/android/nl/xservices/plugins/SocialSharing.java b/src/android/nl/xservices/plugins/SocialSharing.java index a722bc60..9c4ab687 100644 --- a/src/android/nl/xservices/plugins/SocialSharing.java +++ b/src/android/nl/xservices/plugins/SocialSharing.java @@ -271,7 +271,12 @@ public void run() { final boolean hasMultipleAttachments = files.length() > 1; final Intent sendIntent = new Intent(hasMultipleAttachments ? Intent.ACTION_SEND_MULTIPLE : Intent.ACTION_SEND); final Intent receiverIntent = new Intent(cordova.getActivity().getApplicationContext(), ShareChooserPendingIntent.class); - final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT|PendingIntent.FLAG_IMMUTABLE); + + int flag = PendingIntent.FLAG_MUTABLE; + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.S) { + flag = PendingIntent.FLAG_UPDATE_CURRENT; + } + final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, flag); sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); try {