i have this Handler:
private Runnable mRunnableReset = new Runnable() {
public void run() {
Log.i("MyApp", "mRunnableReset");
}
};
private Handler mHandler = new Handler();
private Runnable mRunnable = new Runnable() {
public void run() {
while (true) {
try {
Thread.sleep(2000);
mHandler.post(mRunnableReset);
} catch (Exception e) {
// TODO: handle exception
}
}
}
};
I tried to use this code in my onDestroy() method
mHandler.removeCallbacks(mRunnableReset);
mHandler.removeCallbacksAndMessages(null);
but the mRunnable is still running (i can see the log in LogCat). If I use mRunnable.destroy() my app crashes.
How can i stop this ? Thank you.