Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Killing android application from task manager kills services started by app

My application has one activity which starts two services but does not bind them. If I select return button to exit application (I cannot see it in task manager), both of the services started by application keep running. However, if I goto task manager and kill application, both of the services are stopped. I am not sure if it is intended behaviour but I want the services to keep running even after application exits. Any thoughts please.

Thanks

like image 729
Androidme Avatar asked Jul 06 '12 14:07

Androidme


2 Answers

That is the intended behavior of Task Managers (and force stop in ManageApplication). What good would stopping an application do if it left running the background work that the application was doing?

There is no way for you to prevent the user from killing your service on a stock version of Android OS

like image 198
FoamyGuy Avatar answered Sep 22 '22 02:09

FoamyGuy


This is the behaviour expected. Services do not run in their own process. When you application is killed, your entire process dies with it.

In the documentation I attached, there is an orange block a page down (unfortunately, I don't think I can link to it :-( ) That will tell you pretty much what a service is in a nutshell.

like image 37
ahodder Avatar answered Sep 18 '22 02:09

ahodder