1

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.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Winfred
  • 875
  • 6
  • 12

1 Answers1

3

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.

Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73
  • thanks for your comment, I was thinking more about particular concerns (code) that happened/exist in some actual projects. I should have asked better. – Winfred Jun 13 '11 at 03:20
  • 1
    @Winfred: You want a practice that reduced energy consumption directly. How about Caching, Caching, Caching! Do not ever do the same thing twice and do not create spurious objects again and again and again. Just Cache everything that you can and you should notice speedups as well as better battery life. Other than that it is to general. You need to provide an example and say "How can I make this example perform better?" Because the efficiency of you app is highly dependent on the circumstances and the best battery saving option for one app may actually be a really bad fit for another. – Robert Massaioli Jun 13 '11 at 03:26
  • Thanks. I understand that it is difficult to generalise different practices into a general pattern. However, this is exactly what I needed to do (or at least try to). I'll check out how caching helps and weigh against the additional memory needed. – Winfred Jun 13 '11 at 03:49
  • Thanks all, I'm aware of all of those existing conventional patterns- caching, proximation, avoid FP, reduce CPU/memory usage etc.... my question wasn't well written, my bad, i was thinking about mobile phone related ones. – Winfred Nov 27 '12 at 03:15