I have an app that runs in the background indefinitely provided there
is work to be done. I want the app to go to sleep if there is no work
to be done and the user is idle. The second part has me stumped. On
Windows Mobile I was able to poll the power state to determine user
idleness. On BlackBerry I was able to poll the device idle time.
However, there does not appear to be a way to determine user idleness
on Android.

Instead of polling for user idleness directly, I thought I might be
able to use the on/off state of the screen. There are 2 intents
ACTION_SCREEN_OFF and ACTION_SCREEN_ON and I was able to setup a
listener for these (BroadcastReceiver). The problem is that I do not
know how to determine the current state of the screen at the time I
register the listener, therefore I have to wait until the next screen
on/off change to know anything. The docs speak of some intents that
are "sticky" and thus will allow the current state to be determined,
but the screen events do not appear to have that property. What am I
to do?

In general, I find the lack of support for polling system state
properties (e.g. screen state, power state, signal strength) in
Android to be annoying. It's cool that one can listen for changes in
system state rather than constantly polling for them, but one still
needs to know the current state of the property at the time the
listener is registered. Am I missing something fundamental?




-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to