Is it possible in Android API level 15 to receive a notification whenever the user does anything that keeps the device awake - in effect, whenever PowerManager.userActivity()
is called?
(Bit of background: I'm working on a large Android app for a non-mobile device with a fixed power supply. When the user interacts with the screen, keyboard, etc. I need to send a "stay awake" signal to another, connected device.)
Well if its your own Activity
then you can always use onUserInteraction()
and onUserLeaveHint()
methods.
An alternative way is to listen for all touch events from a Service
using techniques mentioned here: Creating a system overlay window (always on top)
Wouldn't it be enought to trigger your signal on android.intent.action.ACTION_SCREEN_ON
(when the screen is ON) or android.intent.action.USER_PRESENT
broadcast? Read more here: http://developer.android.com/reference/android/content/Intent.html#ACTION_USER_PRESENT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With