I have a variable and I have set it to 3. every time when button is clicked it is decremented and required action is performed. when it reaches 0 i want action should be display on the screen for a while and then it moves to new activity.
But problem is when it reaches 0 it does not hold for a while for the user to see the what action is performed it simply jumps to next page …
is there any way to do this?
the code I’m using is:
if(ch==0)
{
try {
Thread.sleep(15*1000);
startActivity(new Intent("com.example.quizproject.Menu"));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
after using this code,the variable reaches 0 , it doesn’t finishes the previous action rather pause then move to the next activity.
Any possible solution for this problem?
Why do you want the thread to sleep? You will look up the main thread and the user will not go to the Intent as the thread(sleep) is before the Intent.
That’s why.
so: