Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to minimize battery drain in a heavy service

I would like create a service to do something when some "hot situation" occurs, and by "hot situation" I mean the following:

  • the GPS/cell coordinates are in a known zone
  • a known Bluetooth device is detected
  • a known Wi-Fi network is detected
  • weather info has changed
  • considerable change in acceleration of device detected: eg. from walking to travel by car.

As one can see, these tasks are "heavy" and will be run frequently – say, 15 minutes, but sometimes even more – when I have to detect the acceleration of the device.

The question I have is this: will this service drain the battery heavily?

If so, what recommendations do you have to minimize battery drain from the tasks described above?

like image 403
Pentium10 Avatar asked Dec 08 '22 04:12

Pentium10


2 Answers

This might be of interest to you:

Coding for battery life

like image 92
Russell Troywest Avatar answered Dec 27 '22 11:12

Russell Troywest


GPS is the top battery drainer - by having it on all the time, the battery duration will probably be cut down to half. Wireless connection is also quite a big drainer. If your app is working via the cell network, then if the phone is connecting to 3G then that probably drains as quickly as wireless connection anyway (maybe even more)...

I would suggest rethinking the usage of your service. Maybe make it into an app and have the user explicitly turning it on when he thinks to be in a "hot situation". Leave it as a service and the user might start thinking of your app as some sort of malfunctioning program and that will hurt severely your downloads/sales.

Also, to keep track of your apps battery usage, you can visit the "Battery usage panel" that lives inside Android preferences.

like image 25
rui Avatar answered Dec 27 '22 11:12

rui