tags:

views:

501

answers:

1

I made an application in android and used timer like this..

try {
    CountDownTimer  start1 = new CountDownTimer(20000, 1000) {

        public void onTick(long millisUntilFinished) {
                TextView timeShow = (TextView)findViewById(R.id.showTime);
        timeShow.setText(" "+" 00:" +millisUntilFinished / 1000);
            }

But my problem is i don't know how to stop timer. Any idea?

I already tried:

quitApplication.setOnClickListener(new OnClickListener() {
    public void onClick(View v) { 
        start1.cancel(); 
        Intent i = new Intent(v.getContext(), startGame.class);
        startActivity(i);
        // TODO Auto-generated method stub 
    } 
}); 
A: 

call start1.cancel() when you want to stop the timer

Prashast
i have already try it but it does not support.
RBADS
Can you show us how you are doing that? Perhaps, the problem could lie there...
Prashast
I used start1.cancel as following...quitApplication.setOnClickListener(new OnClickListener() { public void onClick(View v) { start1.cancel(); Intent i = new Intent(v.getContext(), startGame.class); startActivity(i); // TODO Auto-generated method stub } });
RBADS