2

i have a requiremet that i want run service continuously in backgroud and it cannot be top by user or it cannot be force stop by going in manage application. is there any way to get notification when user is trying force stop service? or any way to hide our application in android.

i have done START_STICKY but it can't work. it can be possible to write our code on android system services(or system code) that can't be killed or kernel level coding ?

my main criteria is that my service cannot be killed by user

please help me in this

thanks in advance

Dirk Jäckel
  • 2,979
  • 3
  • 29
  • 47
Sumit Prajapati
  • 91
  • 1
  • 12

1 Answers1

2

First of all, a process hosting a service can always be killed by the system if it is in a low memory situation. You service will not even notice that it has been killed, it won't even get onDestroy(). If your service is doing something that the end user is directly aware of (e.g. playing music) you should start the service in foreground (using startForeground) to make it less likely that the system will kill it in a low memory situation.

If a service gets killed by the end user or the system, it will be restarted again when needed or when there are resources available.

Having that said, what you want to do isn't possible, by design. Either your criteria is based on some misunderstanding of how Android works, or your application is supposed to do something that it wants to hide from the end user (which is very questionable).

  • my service is not doing that aware of end user it will be on end user as spy. user is not aware of application is install in their phone can i do that start two services which will watch on other services wheather one is working (or stop) ? – Sumit Prajapati Feb 08 '12 at 05:23
  • I'm sorry, but unless you are targeting rooted devices, or have access to the platform on those devices you are targeting, you simply can't do what you want to do simply since Android is designed to protect the end user from applications that doesn't act in user’s best interest. –  Feb 08 '12 at 06:17
  • thanx for answer so it cannot be possible to create spyware in anroid ? – Sumit Prajapati Feb 08 '12 at 10:43
  • If this answer helped you, please consider up voting it or at least accept it so the question doesn't show up as unanswered anymore. – Dirk Jäckel Jun 21 '12 at 10:41
  • @bergsell in this case its protecting the user from an app that drains the battery or hides from the user. I don't think Android has countermeasures against spyware. – Dirk Jäckel Jun 21 '12 at 10:42