0

I have a background service that runs for a period of about 10 hours. During this period it acquires information from one of the phone's sensors (about 300 TIMES PER SECOND), processes the information, and uploads the processed information to a database file (about every 15 SECONDS).

I have already implemented foreground but the service still shuts down after a few hours.

Before I transferred this process to a service it was in an activity. I had to keep the screen on for 10 hours during the process and it worked with about a 50% drain on battery.

What would be best for performance and then for battery? Implementing WakeLock or AlarmTimer in the background service.

Please don't suggest things like use a power cable because it wouldn't fit the parameters of my app and I really dont need to if I only got a 50% drain on battery with the screen on.

I just need to know what would be the best way to keep the CPU alive so the service doesn't get killed

  • With that kind of requirement, I expect you'd need an external power source, and likely an OS which (unlike Android) is intended to support such kind of high-availability 3rd party tasks. – Chris Stratton Jan 30 '14 at 01:50
  • when i initiated a step to keep the screen on when the service was an activity... the battery lasted throughout the process and still had more than 40 percent battery. Of course the screen was dimmed to its lowest visible setting... but since then i switched this to a background service so the screen wouldnt have to be on all the time – LousDColeman Jan 30 '14 at 04:42

0 Answers0