I have a timer thread:
Thread updateTimerThread = new Thread(new Runnable()
{
@Override
public void run()
{
long updatedTime = 0L;
long timeInMilliseconds = 0L;
timeInMilliseconds = SystemClock.uptimeMillis() - startTime;//System.currentTimeMillis() - startTime;
updatedTime = timeSwapBuff + timeInMilliseconds;
int secs = (int) (updatedTime / 1000);
int mins = secs / 60;
secs = secs % 60;
int milliseconds = (int) (updatedTime % 1000);
timerValue.setText("" + mins + ":"
+ String.format("%02d", secs) + ":"
+ String.format("%03d", milliseconds));
customHandler.postDelayed(this, 100);
//updateTimerThread.start();
}
});
I start it like this:
updateTimerThread.start();
Then to stop it i tried:
updateTimerThread.stop();
But i see a black line over the work stop.
My question is if it's fine ? What is this black line over the stop ? Maybe i need to use something else then stop ?
What i need it to do is when i click to stop it it will pause stay on the time it was getting to and when i will click start again it will start the timer over again.
So maybe i don't need stop maybe somehow to pausing it ? And when i make start again it will reset it and will start from the beginning ?