Spoonface
Spoonface

Reputation: 1563

CountDownTimer updating and blocking

If understand CountDownTimer correctly, it doesn't run on a separate thread from the activity that started it. So does that mean if I start a CountDownTimer in my main activity, and another piece of code later blocks in the activity, does this mean the CountDownTimer will no longer update as the thread is tied up?

and if so, would the CountDownTimer attached to the main activity also stop updating if I launch a second activity?

Upvotes: 5

Views: 1119

Answers (1)

nandeesh
nandeesh

Reputation: 24820

If the CountdownTimer is started in the main thread, then any blocking call in the main thread will delay the Ontick and Onfinish().

But the second part is not true, since even if the next activity is started, the main thread is still running. So the CountdownTimer will continue to run even if you launch the second activity

Upvotes: 2

Related Questions