开发者

Activity killed by system when idle

I am writing a Location service programming that when the user go outside a predefined zone, the App will create a Notification at task bar. I am suffering from the system killing my App Activity automatically. After I hide the App by pressing Home button, the App Activity killed by system automatically after an hour. The problem is the user cannot get 开发者_Python百科any notification after the Activity killed by system. Note: My GPS code is in the Activity Class without creating a Thread for it.

Is it possible to solve the problem by using Service? Is it possible that the Service killed by system also?


Absolutely, create a service, put your code there, make sure it's not too expensive (battery hog etc.) and that should do the job AndroidBegginer - i like the username good one


I am suffering from the system killing my App Activity automatically. After I hide the App by pressing Home button, the App Activity killed by system automatically after an hour.

Of course. This is normal behavior. Android is reclaiming that RAM to be able to run something else. This is no different than a browser app freeing memory associated with Web pages that it downloaded an hour ago, to have more memory for downloading future pages.

Is it possible to solve the problem by using Service?

Yes, a service can run independently of an activity.

Is it possible that the Service killed by system also?

Yes, Android will kill off your service after some period of time. More importantly, the user will kill off your service after some period of time, either via a task killer or the Manage Services screen in the Settings app. Your service needs to die, because if it does not, the user's entire phone will die, because it will run out of battery life. GPS is a significant battery drain -- the phone will only be able to run for a handful of hours before it runs out of charge.

I am writing a Location service programming that when the user go outside a predefined zone, the App will create a Notification at task bar.

This is very possible to write. It is somewhat difficult to write well, in ways that will provide this functionality while not causing excessive battery drain.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜