To close the current activity and start another activity if the user does not do any work on the present screen.
Say I am at Activity1 and I am not doing any work for 30 seconds. I want that another activity say Activity2 starts automatically and Activity1 finishes.
To close the current activity and start another activity if the user does not
Share
You can create a variable and store the system time in it when Activity1 starts.
Refer this link for current System time:
Get current time and date on Android
Then you can create a loop and check whether the variable’s value is less than 30 sec from the System’s current time. If yes you can call a method.
In the method you can start the new activity (Activity2).