Android Code Snippet Starter service and the missing foreground service type crash

I recommend adding these two snippets to avoid crashes that happen when the app is somehow started while the screen is turned off:

Add to manifest editor:
B4X:
SetServiceAttribute(Starter, android:foregroundServiceType, shortService)

Add to starter service:
B4X:
Private Sub Service_Timeout(Params As Map)
    Service.StopForeground(51042) 'this is the id of the automatic foreground notification
End Sub

It will probably be added to the templates in the future.
 

Magma

Expert
Licensed User
Longtime User
1757329291748.png

Well it seems having problem only at specific version of Android...
the problem continues...
 
Top