java - android COuntDownTimer stop and start new one -


the program making includes 2 different count down.

first, user has type in password within time limit , press button. if user can't input password before time limit, over. however, if user able input password correctly before time limit, new timer should start.

    public class malibucountdowntimer extends countdowntimer {     public malibucountdowntimer(long starttime, long interval)     {         super(starttime, interval);     }     @override     public void onfinish()     {         if(hasplanted == false) {             text.settext("time's up!");             mtextview.settext("cya");             btnenable(false);             startb.setenabled(false);         }     }     @override     public void ontick(long millisuntilfinished)     {          text.settext(""+string.format("%02d:%02d:%03d",                     timeunit.milliseconds.tominutes(millisuntilfinished) - timeunit.hours.tominutes(timeunit.milliseconds.tohours(millisuntilfinished)),                     timeunit.milliseconds.toseconds(millisuntilfinished) - timeunit.minutes.toseconds(timeunit.milliseconds.tominutes(millisuntilfinished)),                     timeunit.milliseconds.tomillis(millisuntilfinished) - timeunit.seconds.tomillis(timeunit.milliseconds.toseconds(millisuntilfinished))                     ));         } } 

this first timer, , working fine. however, having trouble trying stop timer when user entered correct password.

i have created class of countdowntimer, , when user input correct password within time limit, second timer starts. put boolean stop first timer when ends, have no idea how can stop counter.

first have create service , call service in main class timer running , call onreceive method

broadcastreceiver br = new broadcastreceiver() {         @override         public void onreceive(context context, intent intent) {             //here check timer running or not               timer.cancel(); }     }; 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -