A
A
Alexander Drek2015-03-24 12:05:32
Android
Alexander Drek, 2015-03-24 12:05:32

Android how to create a non-killable service?

Maybe I don't know how to use Google, but after digging around for a day, I still haven't found the answer.
In general, the task is this, there is an application, it is every 10 seconds. requests a list of new requests from the service. There are two tasks:
1. so that after closing the application it continues to check applications and issue notifications
2. when the device is turned on, it also starts checking applications in the background
Roughly speaking, it worked like gmail, in terms of notifications.
For the first task, I did not find anything at all, for the second task I tried this - stackoverflow.com/questions/1056570/how-to-autosta... option, but it does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marat S, 2015-03-24
@drekon

Your problem has 2 solutions.
1. this is startForeground(NOTIFICATION_ID, new Notification()); after that, consider your service will be almost unkillable (in fact, the system can kill it)
, but, a notification will appear in the status bar that such an application works, this is not bad, but even convenient.
stackoverflow.com/questions/6645193/foreground-ser
...
stackoverflow.com/questions/20636330/start-sticky-...
2. use an alarm manager in the service, which will conditionally start itself after 10 seconds.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question