I am doing a battery consumption study on an Android phone. I want to run Battery Check every 10 minutes until the battery dies completely. I had problems to make it work.
From my first attempt, I use the timer in the service class and plan to check the battery every 10 minutes. But I soon found that the service stopped when the screen went blank.
Then I try to use AlarmService, I use an alarm to wake up my service every 10 minutes and check the battery level and save the data in a file on the SD card. It works with a screen. However, I received the data in only 9 hours ... it seems that the AlarmService stops at some point after a few hours. I do not know why this is so, the system robbed him for memory problems?
So my question is: did anyone write any service to run (as always) in the background before? How do you do this and I really appreciate the sample code?
Currently, I am reading a few reports that there is a partial trace blocker that I can use to maintain the service. Is this the right way to do this?
Thanks a lot and I hope I can get some useful answers here.
android
sunocky Feb 23 '10 at 23:44 2010-02-23 23:44
source share