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?


Asked by: Aston100 | Posted: 24-01-2022






Answer 1

This might be of interest to you:

Coding for battery life

Answered by: Ada342 | Posted: 25-02-2022



Answer 2

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.

Answered by: Freddie300 | Posted: 25-02-2022



Similar questions

Minimize button missing on Android SDK and AVD Manager when launched from Eclipse

I recently switched my developing platfrom from win7 to ubuntu 11.04. Installation was pretty straight forward however I started notice things are different. First, the Android SDK and AVD Manager, when launched from Eclipse, does NOT have the minimze button. If I right click on the top bar, the minimize option is disabled. What's going on there? Although I can easily moved to another desktop so it doesn't interfere with c...


android - Minimize activity on back key press

OnBack Key press i want to minimize the application, How can i do this??? public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { //Here i want to put minimize code.. pls give me this statement return true; } return super.onKeyDown(keyCode, event); } Thanks


android - Install via OTA, app starts from splash when minimize and re-enter

For simply, I write an app with Splash, Home, Child1 and Child2 with following flow: Splash -> Home -> Child1 -> Child2. And we can back from Child2 to Child1, from Child1 to Home, and back from Home to exit app. It sounds simple. I can navigate between these screens correctly. Problem when I install app via OTA. After enter Splash -> Home -> Child1 -> Child2. Staying Child2, I press HOME button to minimize...


"Minimize" an Activity in Android (don't finish it)

I want to "minimize" the application, leaving it in background doing exactly the same that when the home button is pressed when the user clicks a button (but don't finish it) How can I do that?


Keycode for Android minimize soft keyboard button

I'm using the soft keyboard for Android 3.2. The problem is I can't find the keyCode for the button on the bottom left that minimizes the keyboard. I used a switch case for onKeyDown to display the keyCode and it seems to be the only one without a value. I figured it would have the same code as the back button since that is what it replaces but no such luck.


android - When using custom Fonts, is there a way to minimize the size they use?

We've added Arial, Arial Italic, Arial Bold, and Georgia Italic - the APK jumped from ~ 500K to > 1.5MB Is there any way at all to minimize the cost of file size with using custom fonts?


android - How can I minimize a wakeup alarm's running time overhead?

My code logic is like Set a repeated wakeup alarm. alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), 60000, pIntent); during onReceive() of the receiver. do something very quick, may just need 100ms at most. The operation will repeat every minute and it will be battery burden somehow ( since we want to the background service run as lon...


android - Image Quality distort when minimize the height and width of bitmap

I have a bitmap downloaded from internet and now i want to decrease the height and width of bitmap without losing the quality of bitmap. How to achieve this. This is way for downloading bitmap from internet. URL url_1 = null; try { url_1 = new URL(vmImageUrl); bmp = BitmapFactory.decodeStream(url_1.openConnection().getInputStream()); } catch (Exception e) { ...


back button - Android Apps: Exit vs Minimize

Is there an Android standard or coding convention / best practice that says whether or not an app should Exit (not running in background) or minimize (running in background) when the user "backs-out" of an app? For example, you are on the home page of an app. What is the best-practice for handling the back press? The obvious answer is to let android handle it's own back button press, which in turn exits the app. Bu...


javascript - minimize and maximize the map using fingers only - Android

I have an application built in Html5 and wrapped in PhoneGap. In my application I use Google's map-Map, In the smartphone I cant minimize and maximize the map using fingers only, Is there a setting that should allow to be possible to do so?






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top