In my module I have to perform some idle state events.I have gone through this How to detect USER INACTIVITY in android and Android Best Way to Detect and Handle User INACTIVITY this tutorial.. now I just wanted to know how to get the last button pressed time so that if the any other button of my app is not being pressed for several seconds the idle state events should start.. please help me ....
Asked
Active
Viewed 123 times
1 Answers
0
you can use
public long startTime;
startTime = System.currentTimeMillis();
then later on
public long elapsedTime;
elapsedTime = ( System.currentTimeMillis() - startTime);
then to break it down
int hour = (int)((((elapsedTime/1000)/60)/60)%60);
int minutes = (int)(((elapsedTime/1000)/60)%60);
int seconds = (int)((elapsedTime/1000)%60);

JRowan
- 6,824
- 8
- 40
- 59