开发者

android service persistent

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 m开发者_高级运维ore 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.


Some could explain to me how to make a service or an application persistent in android?

You don't. You write your app such that it does not need to be in memory all of the time.

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.

Please use AlarmManager and an IntentService, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜