Android Question 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

Declan

Well-Known Member
Licensed User
Longtime User
I have a B4X app that receives Firebase Notifications.
When the app is running, I receive FB Notifications with no problem.
However, if the app is running in the Background, I receive the following error:
B4X:
** Activity (splash) Pause event (activity is not paused). **
B4XPage_Background
** Activity (splash) Resume **
B4XPage_Foreground
** Activity (splash) Pause event (activity is not paused). **
B4XPage_Background
java.lang.IllegalArgumentException: com.ecowatch.AVPsecure: 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.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:401)
    at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:484)
    at android.app.PendingIntent.getActivity(PendingIntent.java:470)
    at android.app.PendingIntent.getActivity(PendingIntent.java:434)
    at com.google.firebase.messaging.CommonNotificationBuilder.createContentIntent(com.google.firebase:firebase-messaging@@20.3.0:125)
    at com.google.firebase.messaging.CommonNotificationBuilder.createNotificationInfo(com.google.firebase:firebase-messaging@@20.3.0:27)
    at com.google.firebase.messaging.CommonNotificationBuilder.createNotificationInfo(com.google.firebase:firebase-messaging@@20.3.0:9)
    at com.google.firebase.messaging.DisplayNotification.handleNotification(com.google.firebase:firebase-messaging@@20.3.0:27)
    at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(com.google.firebase:firebase-messaging@@20.3.0:65)
    at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@20.3.0:44)
    at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@20.3.0:27)
    at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@20.3.0:17)
    at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging@@20.3.0:43)
    at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@17.6.0:2)
    at java.lang.Thread.run(Thread.java:1012)
I don't understand the use of "FLAG_IMMUTABLE" / "FLAG_MUTABLE" or where is is required/set in the code.
 

DonManfred

Expert
Licensed User
Longtime User
However, if the app is running in the Background, I receive the following error
are you sure to use B4A 13 with an updated SDK?
Did you change FirebaseMessaging Service to a FilebaseMessaging Receiver?

Check the Tutorial
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
are you sure to use B4A 13 with an updated SDK?
Yes, B4A 13.00
I have a number of apps that use the FB notifications and it is my understanding that nothing on the B4A had to be changed, only on the B4J side that pushes the FB notification.
Check the Tutorial
Yes, all requirement have been met.
Notifications are received when the app is running, but not when app is in the background.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
From the error, I guess this problem only happened in Android 12+ (API 31).
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…