omerjerk
omerjerk

Reputation: 4259

How to get to know if a Thread is running in Android

I'm making a thread the usual way and named it "Encoder". If the app closes and restarts again the object of the Thread is destroyed and recreated. Is there a way to get to know if the Thread that I started before is still running or not. ?

Upvotes: 0

Views: 68

Answers (2)

Budius
Budius

Reputation: 39836

You're designing your app wrong.

If the Thread will carry on the work after the activity died, and a new activity should be able to "pick up where the last one left", you should be using a Service to do this work and bind your activity to it.

You can read more about it and how to implement it here: http://developer.android.com/guide/components/bound-services.html

Upvotes: 1

dreambit.io dreambitio
dreambit.io dreambitio

Reputation: 1902

You can use method .isAlive();

From doc:

Tests if this thread is alive. A thread is alive if it has been started and has not yet died.

Upvotes: 0

Related Questions