3

I wish android app to run background service that will do HTTP request every minute and show notifition when server will return certain code.

I did that and I marked server as START_STICKY to keep it in memory. But after few days I noticed service is not running.

How to debug that situation? Android was not rebooting for 21 days according to uptime

I exppected that if android unloads service when low memory then it will run it again later. It has not killed any other service like games

while(true){
    try{
        // queries HTTP server
    }catch(Exception ex){}
}

What may kill service and how do I make it more stable like vibers or skypes

1 Answer 1

2

There is no way to keep a single process running forever, in Android. START_STICKY will not save it!

Have a look at the AlarmService. You should be able to accomplish your goal by scheduling the delivery of an intent, to your app, every minute.

Be aware that this is a pretty battery-unfriendly thing to do. People get pretty sensitive about battery use, and scheduling an HTTP request every minute is gonna kill it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.