EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 905 forks source link

Fix Android 12 Target-SDK 31+ issues #1182

Open ygpedroso opened 1 year ago

ygpedroso commented 1 year ago
kiwi-x commented 1 year ago

This pull request fixes all my problems I had with Cordova Android 11, too!

mreis1 commented 1 year ago

@ygpedroso Thanks. Working just fine.

saggio89 commented 1 year ago

This is similar to PR #1158 which was merged into master. The difference is this has an "If" condition.

int pendingIntentValueFLAG = PendingIntent.FLAG_UPDATE_CURRENT;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
     pendingIntentValueFLAG = pendingIntentValueFLAG | PendingIntent.FLAG_IMMUTABLE;
}
final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, pendingIntentValueFLAG);

@ygpedroso is this needed for backwards compatibility for older versions of Android?

kiwi-x commented 1 year ago

yes I think so, 'cause on older Android Version (< Android S) You probably don't have the FLAG_IMMUTABLE flag.