From 0f10858334e283a28dbebb2bb888f9c7656f5060 Mon Sep 17 00:00:00 2001 From: Elton Henrique Faust Date: Fri, 29 Jul 2022 10:00:12 -0300 Subject: [PATCH] Fix flag only added on sdk 23 (cordova supports sdk 22) --- src/android/nl/xservices/plugins/SocialSharing.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/android/nl/xservices/plugins/SocialSharing.java b/src/android/nl/xservices/plugins/SocialSharing.java index a722bc60..79d0c7e1 100644 --- a/src/android/nl/xservices/plugins/SocialSharing.java +++ b/src/android/nl/xservices/plugins/SocialSharing.java @@ -271,7 +271,8 @@ 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); + final int pendingIntentFlag = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT; + final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, pendingIntentFlag); sendIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); try {