OSDN Git Service

PreferenceActivity should not leave message in looper when destroyed
authorHiroaki Kuriyama <hiroaki.kuriyama@sonymobile.com>
Fri, 16 Nov 2012 09:46:49 +0000 (18:46 +0900)
committerTakeshi Aimi <takeshi.aimi@sonymobile.com>
Fri, 12 Jul 2013 06:42:35 +0000 (15:42 +0900)
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

index 09ff7be..d4e85ed 100644 (file)
@@ -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) {