How to make a daemon or service that can run forever and never exit in Android? -


this question has answer here:

the service in android killed if resources of device not enough.how can make daemon or service live forever , never exit?

a started service can use startforeground(int, notification) api put service in foreground state, system considers user actively aware of , not candidate killing when low on memory. (it still theoretically possible service killed under extreme memory pressure current foreground application, in practice should not concern.)