怎么使service不被杀掉

   阅读
如何使service不被杀掉?
我在自己的应用中启了一个service,这个service是用来保护用户隐私的,所以该service不允许通过任务管理器等类似工具将service杀掉或停掉,求实现方法或思路,谢谢!

------解决方案--------------------
用Foreground Service吧。
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.html
有个例子的。

抛个Notification 上去,但是不同于一般的Notification,她必须用setForeground来关掉。一般的cancel是不起作用的。
------解决方案--------------------
Running a Service in the Foreground
A foreground service is a service that's considered to be something the user is actively aware of and thus not a candidate for the system to kill when low on memory. A foreground service must provide a notification for the status bar, which is placed under the "Ongoing" heading, which means that the notification cannot be dismissed unless the service is either stopped or removed from the foreground.

For example, a music player that plays music from a service should be set to run in the foreground, because the user is explicitly aware of its operation. The notification in the status bar might indicate the current song and allow the user to launch an activity to interact with the music player.

To request that your service run in the foreground, call startForeground(). This method takes two parameters: an integer that uniquely identifies the notification and the Notification for the status bar.

详细请参考http://developer.android.com/guide/topics/fundamentals/services.html
------解决方案--------------------
探讨
杀不掉应该做不了,但是杀掉再重启就可以做到
阅读