Android Question Service.StartForeground(1, Notif1) under Android 13

peacemaker

Expert
Licensed User
Longtime User
HI, All

How to use a foreground service under Android13, if notifications are not required ?
Locally working app with timers and screen.

B4X:
Sub Service_Create
Notif1.Initialize2(Notif1.IMPORTANCE_LOW)
Service.StartForeground(1, Notif1)

Notif1 is required for StartForeground, but
java.lang.ClassCastException: anywheresoftware.b4a.objects.NotificationWrapper$NotificationData cannot be cast to android.app.Notification
 

peacemaker

Expert
Licensed User
Longtime User
full stack trace from the logs.
 
Upvote 0

Rasoull

Member
I have the same problem, did you find a solution?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, Erel. So, for notifications the .SetInfo method is the must for usage, and requesting PERMISSION_POST_NOTIFICATIONS also.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
But if it needs a foreground service, but without notifications - it is not possible, as i can understand, as at least one notification must be made for service creation.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…