Hello,
When I run the application I get the following error:
I'm using B4A 12 with targetSDKversion="31"
Currently the code looks like that:
Any hint on how to solve this?
Thank you.
When I run the application I get the following error:
B4X:
notification_createnotification (java line: 204)
java.lang.IllegalArgumentException: ro.yo3ggx.rxtxe: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
I'm using B4A 12 with targetSDKversion="31"
Currently the code looks like that:
B4X:
Private Sub CreateNotification(Title As String, Content As String, Icon As String, TargetActivity As Object, _
Sound As Boolean, Vibrate As Boolean) As Notification
Dim p As Phone
If p.SdkVersion >= 21 Then
Dim nb As NotificationBuilder
nb.Initialize
nb.DefaultSound = Sound
nb.DefaultVibrate = Vibrate
nb.ContentTitle = Title
nb.ContentText = Content
nb.setActivity(TargetActivity)
nb.SmallIcon = Icon
If p.SdkVersion >= 26 Then
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim manager As JavaObject
manager.InitializeStatic("android.app.NotificationManager")
Dim Channel As JavaObject
Dim importance As String
If Sound Then importance = "IMPORTANCE_DEFAULT" Else importance = "IMPORTANCE_LOW"
Dim ChannelVisibleName As String = Application.LabelName
Channel.InitializeNewInstance("android.app.NotificationChannel", _
Array("YO3GGXChannelId1", ChannelVisibleName, manager.GetField(importance)))
manager = ctxt.RunMethod("getSystemService", Array("notification"))
manager.RunMethod("createNotificationChannel", Array(Channel))
Dim jo As JavaObject = nb
jo.RunMethod("setChannelId", Array("YO3GGXChannelId1"))
End If
Return nb.GetNotification
Else
Dim n As Notification
n.Initialize
n.Sound = Sound
n.Vibrate = Vibrate
n.Icon = Icon
n.SetInfo(Title, Content, TargetActivity)
Return n
End If
End Sub
Any hint on how to solve this?
Thank you.
Last edited: