Why does my app restart when I want to run a timer, in Android Studio?

0

I have the following code in the MainActivity.java

TimerTask timerTask = new TimerTask()
{
    @Override
    public void run()
    {
        Toast.makeText(MainActivity.this, "Timer", Toast.LENGTH_SHORT).show();
    }
};
Timer timer = new Timer();

and on the button to start it I have

timer.schedule(timerTask,10,4000);

and when you press it, my app reboots and the timer does not start.

    
asked by Omar Fernando 17.07.2018 в 01:07
source

0 answers