I had a method that makes me a continuous loop with postAtTime every x seconds using (Handler), except that this method is placed in an activity A, when going into the activity B and then return to A for pressing stop button for finsih loop, I can not stop it with mHandler.removeCallbacks (..) I am attaching here the method
Button Start:
mHandler.postAtTime(mUpdateTimeTask, 100);
Loop:
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
Toast.makeText(getBaseContext(),"ok!",Toast.LENGTH_SHORT).show();
mHandler.postDelayed(this, 1000);
}
};
Button Stop:
mHandler.removeCallbacks(mUpdateTimeTask);
from another activity