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.
Asked
Active
Viewed 176 times
2 Answers
0
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).
//To start new activity
Intent intent=new Intent(your_current_class.this,activity_you_want_to_call.class);
startActivity(intent);
-
i m a newbie.. can you please give the answer with a code....... – sneaker_android Oct 10 '12 at 07:40
-
@user1595120 Welcome to Stackoverflow, please kindly read the FAQ. asking for code is not **digestible** here. – RobinHood Oct 10 '12 at 07:43
-
i m not asking the whole code.. please let me know that how will i check that no operation is performed on the current activity since the past 30 seconds. – sneaker_android Oct 10 '12 at 07:46
-
I have added some references for you. I guess you will be able to handle the loop – kittu88 Oct 10 '12 at 07:49