timer - Stop a updatetimer in android -


i try create custome elapse time , start timer once hold volume key , suppose time must stop after release key have problem when release key timer still moving. please advise on i'm missing thanks

public boolean onkeydown(int keycode, keyevent event) { if ((keycode == keyevent.keycode_volume_down && shouldcont == true && event.getaction() == keyevent.action_down)){ startrecord(); repeat = true; if(repeat == true && event.getaction() == keyevent.action_down ){ t.scheduleatfixedrate(new timertask() {

            public void run() {                 runonuithread(new runnable() {                      public void run() {                         long timegonemillis = system.currenttimemillis() - starttime;                          textview tv = (textview) findviewbyid(r.id.timer);                          tv.settext(""+util.millisecondstotimer(timegonemillis));                                              }                  });             }          },         //set how long before start calling timertask (in milliseconds)         0,         //set amount of time between each execution (in milliseconds)         1000);}         shouldcont = false;     } 

i found out cant kill timer instances using cancel() added t.cancel() , timer instances stop.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -