Den  Stre Den Stre - 7 months ago 172
Java Question

Android Studio Countdown Timer

So I am working with Android Studio and I need a countdown timer.
So far i have searched and found all kinds of code lines that do not work , or do not do exactly what I wanted the app to do.
I want the timer to countdown , if the user answers incorrectly , the time left will be reduced , and if the user answers 3 correct , then time will be added.
Can anyone give me a code and explain what it does , do I need anything extra?
and how i can modify it to my needs.

Answer

You can use the official countdown timer from Google. Look here: http://developer.android.com/reference/android/os/CountDownTimer.html

new CountDownTimer(30000, 1000) {

    public void onTick(long millisUntilFinished) {
        mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
    }

    public void onFinish() {
        mTextField.setText("done!");
    }
}.start();

And then you can manually add/reduce your time with every wrong answer.