Friday, 15 April 2011

android - Should I use [Service w/ Timer] or [Service w/ Thread] for a long running service? -



android - Should I use [Service w/ Timer] or [Service w/ Thread] for a long running service? -

i'm trying create app reads current running application , log how long it's active throughout day.

i've decided utilize activitymanager (since apparently it's way this). i've found/thought of various implementation, , have questions in deciding way best way go in respect battery consumption since service running entire time phone on. example, finding way in service doesn't poll when screen off

1) service w/ timer. think way poll activitymanager, if it's running in service won't service block app's main thread?

2) having service shoot off thread, poll activitymanager , sleep 2 seconds

3) service w/ pendingintent , alarmmanager

in short, method efficient , why?

android

No comments:

Post a Comment