1

I have a requirement where if the user does not respond in two minutes I have to record as missing interaction.

Usecase : pop up survey. If user doesn't respond(inactivity) then I have to end the activity and record as missing data. How can I handle this usecase.

oezi
  • 51,017
  • 10
  • 98
  • 115
Android_enthusiast
  • 863
  • 5
  • 22
  • 41

2 Answers2

1

Android provides the CountDownTimer class. You could just start this timer when the activity loads and then if the user touches the screen cancel the timer, otherwise in the onFinish() of the CountDownTimer you would close the activity.

DRiFTy
  • 11,269
  • 11
  • 61
  • 77
1

What I would do (certainly not the best solution), but I hope that can help you a little bit..

You can use the onUserInteraction to reset a timer.: http://developer.android.com/reference/android/app/Activity.html#onUserInteraction()

@Override
public void onUserInteraction(){
    MyTimerClass.getInstance().resetTimer();
}

EDIT:

Something I found and may help: How to detect USER INACTIVITY in android

Community
  • 1
  • 1
Waza_Be
  • 39,407
  • 49
  • 186
  • 260