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 #2079. Fix a crash when targeting Android 12 #2090

Merged
merged 1 commit into from Mar 24, 2021
Merged

Conversation

ihrupin
Copy link
Contributor

@ihrupin ihrupin commented Mar 18, 2021

Since Android 12 we need to set PendingIntent mutability explicitly.

Here is the documentation: https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

Error message:
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.

Fixes Issue #2079

@CLAassistant
Copy link

CLAassistant commented Mar 18, 2021

CLA assistant check
All committers have signed the CLA.

@ihrupin ihrupin force-pushed the main branch 4 times, most recently from 8079aab to 223762f Compare March 19, 2021 19:08
@ihrupin
Copy link
Contributor Author

ihrupin commented Mar 19, 2021

@pyricau Please review the PR. Thank you!

@@ -39,7 +40,12 @@ internal class NotificationReceiver : BroadcastReceiver() {
): PendingIntent {
val broadcastIntent = Intent(context, NotificationReceiver::class.java)
broadcastIntent.action = action.name
return PendingIntent.getBroadcast(context, 0, broadcastIntent, 0)
val flags = if (Build.VERSION.SDK_INT > 30) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Build.VERSION_CODES.R instead of "30" requires updating compileSDK from 29 to 30. This update caused other issues. So, it is better to do compileSDK update in a separate PR

@pyricau pyricau merged commit 8f61442 into square:main Mar 24, 2021
@pyricau
Copy link
Member

pyricau commented Mar 24, 2021

thx!

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.

None yet

4 participants