Reputation: 1370
Actually i just want to know whether can we set timer when the activity changes.
Detail description:
startActivity(new Intent(this,Second.class));
I know that by using this code we can change one activity to another activity. By the above code when the activity is changing it changes quickly as know to everyone, but what i want is in button click event when i write this code, when i click that button the same activity needs to be on screen for some particular time (i.e., around 10 seconds) & after that it needs to change activity. I thought of keeping timer here but i didn't got any idea how to do that. Can anyone please help me with this.
Upvotes: 1
Views: 555
Reputation: 36035
The easiest thing would be to simply create a Handler and post a message to it 10 seconds later.
Handler activityChanger = new Handler();
activityChanger.postDelayed(new Runnable(){
startActivity(new Intent(this,Second.class));
}, 10000);
Put that where you normally create your activity within the scope of startActivity. You're current activity should run for 10 more seconds and the new one starts up.
Upvotes: 2