I need to use idle listener to listen the user is using the application or idle when the activity is alive.
I need to do something when the user is not using the application more than ten seconds.
How can i make it possible?
I need to use idle listener to listen the user is using the application
Share
Here is the idea how you can achieve this task:
Firstly you need a Runnable(), which will be Run when your timeout(e.g. 10 sec) occurs. Below is the Runnable():
Now, in your activity, you can call postDelayed for the DoOnTimeOut:
Now, most important part is that when you see user interaction, you want to cancel the call to DoOnTimeOut and then again set the call for next 10 sec. Here is the Override method of your Activity for User Interaction:
I hope it will be helpful for you.