Catch System terminate App?

bergapappa

Member
Licensed User
Longtime User
Hi

Have an app that starts a service in intervals.
I have choosen to kill the service, the upcoming schedules and the app when the user clicks the back button. This I do with UserClosed=True
If the user clicks the home button - everything is just kept alive and the scheduled service will fire then the time comes.

But I'm worried what happens if Android would kill the app.
Then I guess my scheduled service will fire when the time comes, is this possible to prevent.
I mean, can I catch the event when Android kill the app?

Regards

Bergapappa
 

bergapappa

Member
Licensed User
Longtime User
You can set a flag (process global variable) named AppIsAlive to true in Activity_Create. Later when your service starts check the variable value. If it is false then destroy the service and return without doing anything.

OK, but how and when will this flag get the value false?

TNX in advance

bergapappa
 
Upvote 0

bergapappa

Member
Licensed User
Longtime User
Great, TNX Erel
So, even if I have given it the value True in Activity_Create. This Boolean flag will be False if Android has killed my activity module?

In your opinion, should I use the check in the Service_Create or in Service_Start sub as below?


Sub Service_Start (StartingIntent As Intent)

If main.AppIsAlive = False Then
CancelScheduledService("slumpljud")
StopService("slumpljud")
End If


Regards
bergapappa
 
Upvote 0

bergapappa

Member
Licensed User
Longtime User
Actually I have some problem testing this as my Galaxy tab does not seem to sun out of resources :)
Started about 12 other apps inkluding a youtube video, and my test app is not killed.

Any tip on how to stress the system inte the best way?
 
Upvote 0
Top