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

android 12 适配 #103

Open
jinlongwu opened this issue Dec 30, 2022 · 1 comment
Open

android 12 适配 #103

jinlongwu opened this issue Dec 30, 2022 · 1 comment

Comments

@jinlongwu
Copy link

PACKAGE_NAME: Targeting S+ (version 10000 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.

@jinlongwu
Copy link
Author

 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
            //android 12 必须使用 PendingIntent.FLAG_MUTABLE 模式
            val pendingIntent = PendingIntent.getActivity(
                context, REQUEST_CODE, intent, PendingIntent.FLAG_MUTABLE
            )
            builder.setContentIntent(pendingIntent)

        } else {
            val pendingIntent = PendingIntent.getActivity(
                context,
                REQUEST_CODE, intent,
                PendingIntent.FLAG_ONE_SHOT
            );
            builder.setContentIntent(pendingIntent)
        }

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

1 participant