Android Quiz Application Count Down Timer
<p>Hi guys i am still working on my capstone project i am working for a quiz application and i need to put a timer which will end the quiz when ever the timer is 0
i need a code where when the activity starts the timer starts too and when it ends it goes to the result activity i already have a code for my quiz activity which contains the answers and questions here is the code please help me where and what to put to achieve that count down timer ur help would be so much appreciated</p>

<pre><code>package org.intercode.lifeatceu;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.provider.MediaStore;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import java.util.HashSet;
import java.util.Random;

public class levelone extends AppCompatActivity {
TextView tv1, tvCred, tvQuestion, tvTime;
Button btNext;
RadioButton rb1, rb2;
RadioGroup rg;

String questions [] = {"Ma. Cristina D. Padolina is CEU's President", "Carlito B. Olaer is the V.P of CEU", "CEU's VISION is to sting every enemy", "One of CEU's Mission is to promote creative and scholarly academic"};
String answer [] = {"True", "False", "False", "True"};
HashSet numbers = new HashSet();


int flag = 0;
Random rnd = new Random();
int flag2 = 0 ;
int score = 0;
int correct = 0;
int wrong = 0;
int coins = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_levelone);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    Intent inquiz = getIntent();
   final int credit = inquiz.getIntExtra("passedCredits", 0);
    String TotalCoins = String.valueOf(credit);



    tv1 = (TextView) findViewById(R.id.tv1);
    tvCred = (TextView) findViewById(R.id.tvCred);
    tvQuestion = (TextView) findViewById(R.id.tvQuestion);
    tvTime = (TextView) findViewById(R.id.tvTime);
    rb1 = (RadioButton) findViewById(R.id.rb1);
    rb2 = (RadioButton) findViewById(R.id.rb2);
    rg = (RadioGroup) findViewById(R.id.rg);
    btNext = (Button) findViewById(R.id.btNext);
    flag2 = rnd.nextInt(4);
    numbers.add(flag2);



    tvQuestion.setText(questions[flag2]);
    tvCred.setText(TotalCoins);

    btNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            RadioButton uans = (RadioButton) findViewById(rg.getCheckedRadioButtonId());
            String ansText = uans.getText().toString();
            if (ansText.equalsIgnoreCase(answer[flag2]))
            {
                while (numbers.contains(flag2))
                {
                    flag2 = rnd.nextInt(4);
                }
                correct++;
                coins++;

            }
            else
            {
                wrong++;
            }
            flag++;
            flag2 = rnd.nextInt(4);
            if (flag &lt; questions.length)
            {
                tvQuestion.setText(questions[flag2]);
            }
            else
            {
                score = correct;
                Intent in = new Intent(getApplicationContext(), Results.class);
                in.putExtra("passedCredits", credit);
                in.putExtra("passedWrong", wrong);
                in.putExtra("passedCorrect", correct);
                in.putExtra("passedCoins", coins);
                startActivity(in);
            }

        }
    });
}

}
</code></pre>

<p>i hope there would be a way to put the timer inside this codes :P</p>