Skip to content

Commit 9a4b0c5

Browse files
authored
chore(ui): drain Handler thread queue when activity is destroyed (#99)
Currently, we don't have any tasks that could execute after the Activity is destroyed and lead to crashes or unexpected behaviors. So, it's better to drain this static Handler thread's queue upon Activity destruction to prevent quite realistic, well-known bugs tied to Android lifecycle that we might face in the future if making any changes.
1 parent 52cb098 commit 9a4b0c5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/com/github/iusmac/sevensim/ui/scheduler/SchedulerActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,11 @@ protected void onPause() {
160160
mSubscriptions.removeOnSubscriptionsChangedListener(this);
161161
sHandler.removeCallbacksAndMessages(mSubscriptionsChangedToken);
162162
}
163+
164+
@Override
165+
protected void onDestroy() {
166+
super.onDestroy();
167+
168+
sHandler.removeCallbacksAndMessages(null);
169+
}
163170
}

src/com/github/iusmac/sevensim/ui/sim/SimListActivity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ protected void onPause() {
145145
unregisterReceiver(mIntentReceiver);
146146
}
147147

148+
@Override
149+
protected void onDestroy() {
150+
super.onDestroy();
151+
152+
sHandler.removeCallbacksAndMessages(null);
153+
}
154+
148155
@VisibleForTesting
149156
final class IntentReceiver extends BroadcastReceiver {
150157
@Override

0 commit comments

Comments
 (0)