I am making an application, in which the user has to answer a series of questions under a certain amount of time, let's say 10seconds. I have gotten most of the code but the timer part. I want the current activity to end and either show a Toast or switch to some different activity.
I tried TimerTask and Timer classes but they don't seem to work, no idea why.
Timer t = new Timer();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
Toast.makeText(LevelOne.this, "Times up!!!", Toast.LENGTH_SHORT).show();
startNextLevel();
}
};
t.schedule(timerTask,5000L );
private void startNextLevel() {
Intent nextLevel = new Intent(this, LevelTwo.class);
startActivity(nextLevel);
}