1

I'm trying to create an app which reads the current running application and log how long it's active throughout the day.

I've decided to use ActivityManager (since apparently it's the only way to do this). I've found/thought of various implementation, and have some questions in deciding which way is the best way to go about it in respect to battery consumption since this service will be running the entire time the phone is on. For example, finding a way in which the service doesn't poll when the screen is off

1) Service w/ Timer. I think this would be a good way to poll the ActivityManager, but if it's running in the service won't the service block the app's main thread?

2) Having a service shoot off a thread, which will poll the ActivityManager and then sleep for 2 seconds

3) Service w/ PendingIntent and AlarmManager

In short, which method would be the most efficient and why?

Community
  • 1
  • 1

0 Answers0