In the onDestory snippet I put the code to clear all pending runnables, I started using Handler.postDelayed.
mUiHandler.removeCallbacksAndMessages(null);
I have a question here. Is it safe to call mUiHandler.removeCallbacksAndMessages (null);? As far as I understand, Android performs all the operations of the user interface, such as the layout of the user interface, visualization of the user interface, component life cycles (onCreate, onPause, onResume) in the main looper. Do I understand this correctly? Then, when I call mUiHandler.removeCallbacksAndMessages (null) in the fragment, it will ruin or clear all the Android user interfaces in the message queue in the main looper, since there is only one message queue in the main looper.
Thanks.
source share