From 1ebf13ef20fea56f55094a3744c9813500a55b17 Mon Sep 17 00:00:00 2001 From: Hiroaki Kuriyama Date: Fri, 16 Nov 2012 18:46:49 +0900 Subject: PreferenceActivity should not leave message in looper when destroyed When a PreferenceActivity is destroyed as soon as created, there is a problematic case that messages for the activity are sometimes left in the looper even after the activity is destroyed. For example, by clearing user data of the selecting IME on Settings apk, com.android.settings.Settings is re-launched 2 times successively. (Destory->Create->Destroy->Create) Due to the left message, application crash can happen. (NullPointerException at BackStackRecord.getBreadCrumbTitle()) Two cases have been found to observe this issue. [Case 1] 1,Launch IME in advance. 2,Go to Settings >Apps > All and choose the IME package. 3,Click "Clear data" 4,Application crash occurs on com.android.settings. [Case 2] 1,Go to Settings > Language&input > Language. 2,ListView dialog to choose language is shown. 3,Rotate the tablet 180 degree so that 90 degree rotation occurs twice. 4,Application crash occurs on com.android.settings. Change-Id: I5ce36ea7a40ab7bc7737b7dca6641a4c3d77a480 --- core/java/android/preference/PreferenceActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java index 09ff7be..d4e85ed 100644 --- a/core/java/android/preference/PreferenceActivity.java +++ b/core/java/android/preference/PreferenceActivity.java @@ -895,6 +895,8 @@ public abstract class PreferenceActivity extends ListActivity implements @Override protected void onDestroy() { + mHandler.removeMessages(MSG_BIND_PREFERENCES); + mHandler.removeMessages(MSG_BUILD_HEADERS); super.onDestroy(); if (mPreferenceManager != null) { -- cgit v1.1