Skip to content

Commit

Permalink
fix(share): avoid crash when targeting SDK 31 (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Apr 1, 2022
1 parent b4e943d commit 275da5f
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,13 @@ public void share(PluginCall call) {
if (title != null) {
intent.putExtra(Intent.EXTRA_SUBJECT, title);
}
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
flags = flags | PendingIntent.FLAG_MUTABLE;
}

// requestCode parameter is not used. Providing 0
PendingIntent pi = PendingIntent.getBroadcast(
getContext(),
0,
new Intent(Intent.EXTRA_CHOSEN_COMPONENT),
PendingIntent.FLAG_UPDATE_CURRENT
);
PendingIntent pi = PendingIntent.getBroadcast(getContext(), 0, new Intent(Intent.EXTRA_CHOSEN_COMPONENT), flags);
Intent chooser = Intent.createChooser(intent, dialogTitle, pi.getIntentSender());
chosenComponent = null;
chooser.addCategory(Intent.CATEGORY_DEFAULT);
Expand Down

0 comments on commit 275da5f

Please sign in to comment.