Android Tutorial A trick for a badly closed application from a KILL TASK

I found it hard to find a solution to a problem that I think someone else could have
if you leave a service running with:

B4X:
#StartCommandReturnValue: android.app.Service.START_STICKY
or
B4X:
Service.StartForeground

The problem appears when someone KILL TASK APP, then your application has not just closed, and sometimes some variables, or service processes prevent the application from running correctly, being useless "even until the next restart of the phone"

The easiest solution I've found and I think it can help someone in a situation like this is add these lines to starter service

B4X:
Sub Service_TaskRemoved
StopService (Me)
ExitApplication
End Sub

When it detects the KILL of the APP, it has just closed the service and the application ...
that way, the next time it is loaded it starts from 0 perfectly
 
Top