问题
ATM, I'm searching through open source/close source android applications to identify particular concerns (code blocks, code patterns) that rise energy issue as my interests and part of studies.
For example, code that
- turning on GPS for longer than necessary , or
- refreshing display unnecessarily.
So,
Is there any suggestion how I can go about searching those concerns and possible fixes?
any professional Android programmers could suggest some common practices that saves energy with example code?
Thanks in advance, sorry for asking an a bit open-ended question.
回答1:
Actually the Android developers wrote a great guide on Designing for Performance so that you could save battery life by not running the CPU full blast all of the time and not running the hardware so much. But the basic gist is to minimise:
- CPU utilization time (do not keep it sitting at 100% usage and use Alarm Manager if that is all you need)
- Hardware Use (do not sit there polling the GPS)
- Screen Use (If you do not need to have the screen on, or it can go dim then let it; do not display a bright white background constantly)
Basically, any use at all will drain the battery and the battery is energy, whatever wastes the devices energy wastes the battery so you should minimize it.
来源:https://stackoverflow.com/questions/6326285/android-app-programming-and-energy-efficiency