0

I am developing a reservation application and i have a requirement for the application to be timeout after 20 mins for inactivity in the application.

which ever the activity the application is in, it should navigate back to home screen (login screen) after time out

Kindly advice me what should be the better approach to do this.

AADProgramming
  • 6,077
  • 11
  • 38
  • 58
nagendra
  • 161
  • 1
  • 1
  • 12

1 Answers1

1

Android does not provide any native support for tracking user inactivity per se. However, you can use a CountDownTimer and bind it with an interface callback like onUserInteracted() and reset the timer whenever it is called. You will also have to take into consideration the lifecycle of an Activity and register/unregister the timer/callbacks accordingly.

You can also refer this sample code to get a fair idea on how to get started - https://stackoverflow.com/a/12481918/3025732

Community
  • 1
  • 1
Joel Fernandes
  • 4,776
  • 2
  • 26
  • 48