i just started working on android about 4 months back. i created a project that uses AlarmManager, the flow is like this: AlarmManager->service->wifi not available->AlarmManager continues->service.. and so on. this alarm may be scheduled for days, hopefully if the device is not rebooted. I required help in the Battery drainage part of the project. How may i know the rate at which my AlarmManager Project is draining the battery. I fear that if it drainin开发者_开发百科g a lot of battery, my app wont be useful.
There are several things which may consume a lot of battery power, such as the display screen, access and Wifi scanning, Bluetooth, GPS, live wallpapers and so on. Roaming around on forums and stuff, I see a lot of people complaining about short battery time, and it is actually easy to understand them, but if they take a closer look at all the resources you mobile is using constantly, they wouldn't be surprised at all. Personally, I've resigned to charge my phone twice a day, when not working with it.
Nevertheless, I have a couple suggestions for you:
I am not actually that familiar with how AlarmManager works, but I suppose you could decrease the frequency of scheduled alarms to save battery time. There are a lot of applications which start automatically, not sure they use this method, though!
Use JuiceDeffender (I think) and JuicePlotter. These are apps which can monitor and plot the battery consumption in time.
Make tests: In one day schedule the alarms, in another day, don't! Then analyse the battery level.
Perhaps the folks in android.stackexchange.com have a deeper knowledge on Android power consumption. Ask them out!
Cheers!
精彩评论