Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue PendingIntent.FLAG_IMMUTABLE app crashed on Android app Target 31 (Android 12) #63

Open
thongbbc opened this issue Jul 5, 2022 · 1 comment

Comments

@thongbbc
Copy link

thongbbc commented Jul 5, 2022

Hello, we have been having this issue on Android app Target 31.
Ref document: https://stackoverflow.com/questions/67045607/how-to-resolve-missing-pendingintent-mutability-flag-lint-warning-in-android-a

I tried with solution add dependency into build.gradle
implementation 'androidx.work:work-runtime:2.7.1'

But it still does not work.

-> My latest solution to fix this which is using patch package to modify Native code

    private PendingIntent getBoundaryPendingIntent() {
        if (mBoundaryPendingIntent != null) {
            return mBoundaryPendingIntent;
        }
        Intent intent = new Intent(getReactApplicationContext(), BoundaryEventBroadcastReceiver.class);
        mBoundaryPendingIntent = PendingIntent.getBroadcast(getReactApplicationContext(), 0, intent, PendingIntent.
                FLAG_UPDATE_CURRENT);
        return mBoundaryPendingIntent;
    }

Change mBoundaryPendingIntent = PendingIntent.getBroadcast(getReactApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); to

    final int flag =  Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
        mBoundaryPendingIntent = PendingIntent.getBroadcast(getReactApplicationContext(), 0, intent, flag);

I think we should create PR for this. Thanks.

@thongbbc thongbbc changed the title Issue PendingIntent.FLAG_IMMUTABLE app crashed on Android app Target 31 (Android 12) #308 Issue PendingIntent.FLAG_IMMUTABLE app crashed on Android app Target 31 (Android 12) Jul 5, 2022
@kyadalu1
Copy link

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

No branches or pull requests

2 participants