Skip to content

Conversation

@ygpedroso
Copy link

  • Since Android 12+ it is required to explicitly set the
    android:exported property when the corresponding component
    has an intent filter defined.
  • Fixes the following Android 12+ issue:
    java.lang.IllegalArgumentException: com.app-xxx: Targeting S+
    (version 31 and above) requires that one of FLAG_IMMUTABLE or
    FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE
    if some functionality depends on the PendingIntent being mutable,
    e.g. if it needs to be used with inline replies or bubbles.

- Since Android 12+ it is required to explicitly set the
android:exported property when the corresponding component
has an intent filter defined.
- Fixes the following Android 12+ issue:
java.lang.IllegalArgumentException: com.app-xxx: Targeting S+
(version 31 and above) requires that one of FLAG_IMMUTABLE or
FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE
if some functionality depends on the PendingIntent being mutable,
e.g. if it needs to be used with inline replies or bubbles.
@kiwi-x
Copy link

kiwi-x commented Aug 29, 2022

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

@mreis1
Copy link

mreis1 commented Sep 1, 2022

@ygpedroso Thanks. Working just fine.

@saggio89
Copy link

saggio89 commented Sep 7, 2022

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
Copy link

kiwi-x commented Sep 7, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants