I want to check if either the Runnable is alive or not in my service. Is there a way i could do this?
private Runnable sendData = new Runnable() {
public void run() {
try {
superToast.show();
screenOn();
vibrate();
mHandler.postDelayed(sendData, time);
} catch (Exception e) {
e.printStackTrace();
}
}
};
you can create a boolean variable and check its value whether it is running or not
boolean isRunning = false;
private Runnable sendData = new Runnable() {
public void run() {
try {
isRunning = true;
superToast.show();
screenOn();
vibrate();
mHandler.postDelayed(sendData, time);
} catch (Exception e) {
e.printStackTrace();
isRunning = false;
}
}
};
and now check for isRunning, if its true it is running else not running
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With