In my application I implemented a remote service that exchange data with a webserver each 20 minutes and modify the value of some object in MyApplication Class that extends Application.
After 12 or 15 hour android kill MyApplication class and/or my Service.
I tried to implement the
android:alwaysRetainTaskState=”true”
without results. Some could explain to me how to make a service or an application persistent in android? I see more application that stay in background for days without problems, but I don’t know how to do that.
I know that android could kill each application if it needs some free memory but my system has 180mb of free memory and no application running because I use it for testing my programs.
You don’t. You write your app such that it does not need to be in memory all of the time.
Please use
AlarmManagerand anIntentService, so your service does not need to be in memory except when it is doing meaningful work. This also means Android is rather unlikely to kill your service while you are in memory, and users are unlikely to kill your service because they think you are wasting memory.