java - How to change the delay of sleep/timer thread in android during runtime? -
what trying decrease timer delay every time counter becomes multiple of 5. but, code entered if block, stopped incrementing timer. can't understand happening.
this code
thread=new thread(){ public void run(){ try{ if(count%5==0) timre--; else{ //do nothing } //*******progress update********// for(t=0;t<=100;t++) { sleep((timre) / 100); progress.setprogress(t); t += 1; } //****progress update over****// } catch (interruptedexception e) { e.printstacktrace(); } { finish(); } }//run ends };//thread ends thread.start();//timer starts
threads (and sleep()
) tricky in android. try using countdowntimer instead
countdowntimer counter; starttimer(); counter.start(); private void starttimer() { counter = new countdowntimer(4000, 500){ @override public void onfinish() { **do stuff here** } @override public void ontick(long millisuntilfinished) { } }; }
call function starttimer()
wherever want , start counter
@ same time.
Comments
Post a Comment