I am using android studio(java) and I want my time to print some text when the time reaches one minute, my current code is;
I want to make a stopwatch. when my stopwatch reaches 1 minute I want it to print a statement, how can i make it do this?
Button btnStart,btnPause,btnLap;
TextView txtTimer;
Handler customHandler = new Handler();
LinearLayout container;
TextView lt;
long startTime=0L,timeinMilliseconds=0L,timeSwapBuff=0L,updateTime=0L;
Runnable updateTimerThread = new Runnable() {
@Override
public void run() {
timeinMilliseconds = SystemClock.uptimeMillis() -startTime;
updateTime = timeSwapBuff+timeinMilliseconds;
int secs=(int) (updateTime/1000);
int mins=secs/60;
secs%=60;
int milliseconds=(int) (updateTime%1000);
String s = "" + mins + ":" + String.format("%02d",secs) + ":" +
String.format("%03d",milliseconds);
txtTimer.setText (s);
customHandler.postDelayed(this,0);
Aucun commentaire:
Enregistrer un commentaire