Remove all pending messages when fragment destroyed

Remove all pending messages when the fragment has destroyed.
Otherwise, after fragment disattachs its context, an exception
will be reported when process the messages.

Bug:377166756

Change-Id: I333cedb45c0fe43b81abbfbe19e37f42f98def91
Signed-off-by: dingfeisong <dingfeisong@xiaomi.corp-partner.google.com>
This commit is contained in:
dingfeisong
2024-11-04 11:15:47 +08:00
parent 94ea022aa1
commit 64aaa1440a

View File

@@ -207,7 +207,9 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
@Override
public void onDestroy() {
mWorkerThread.quit();
if (mHandler.hasMessagesOrCallbacks()) {
mHandler.removeCallbacksAndMessages(null);
}
super.onDestroy();
}