Dimitris
Dimitris

Reputation: 247

How to make my app lives longer in background android?

The main activity of my app takes the current location and send it to server via httppost using asynk. My problem is that when the user push home button and app goes to background after a long time period the system kill my app as it should. onDestroy is called and my app unregistering the locationlistener and also closes the Activity.I tried saveinstancestate method but it doesn't help me.So is any trick to make my activity lives longer in background?

Upvotes: 0

Views: 72

Answers (1)

hendrikbeck
hendrikbeck

Reputation: 670

There's no way to keep your "Activity" alive but you can (and have to) implement an Android Service: http://developer.android.com/reference/android/app/Service.html. Just move your background functionality there.

Upvotes: 1

Related Questions