Is there a trigger for user inactivity (similar to Android's built in Sleep timeout)?
Use case is for where I have a long (or no) Sleep timeout - so the display is on and the device awake - but I want to perform an action after a time of no user interaction.
I kind of want the 'inverse' of the User Present trigger, "User NOT present".
Is there a way to detect, say, when the user last touched the screen (regardless of the app or homescreen the user happens to be on)? Can I use the 'UI Event' trigger in this way?
Trigger for user inactivity?
Moderator: Martin
Re: Trigger for user inactivity?
To my knowledge there's no good way to get access to this information.
You could try Execute Root Command: dumpsys power and see if it includes mLastUserActivityTime and extract the value from there.
Using UI Event could be a workaround but it will also include changes not directly made by the user, for example when Automagic launches an app etc.
You could try Execute Root Command: dumpsys power and see if it includes mLastUserActivityTime and extract the value from there.
Using UI Event could be a workaround but it will also include changes not directly made by the user, for example when Automagic launches an app etc.
Re: Trigger for user inactivity?
Hmm, there might be another approach. Is there a way to determine when a device has gone to sleep because the power button has been pressed rather than becuase the sleep timer has expired? I could detect when the screen goes off (due to the user idle sleep timer), but would need to buld in an exception for when the user themselves has caused this to happen by pressing the power button. I.e. can I just detect when the physical power button is pressed?
Re: Trigger for user inactivity?
That's not easily possible to my knowledge. You could use trigger Command Output to detect the power button press but this method also requires root. The solution with dumpsys power might be even easier.
Re: Trigger for user inactivity?
OK, thanks for your insight