diff options
| author | Amith Yamasani <yamasani@google.com> | 2010-03-18 01:24:03 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-03-18 01:24:03 -0700 |
| commit | 81a291440be651d3d954aefca516bd77abf104dd (patch) | |
| tree | cd69cddfff2fbe4a82d9b5f65ae95571ecbdcdc3 /core/java | |
| parent | 694f79b5d1196640d1beb680b7d1fc68e6e77cbd (diff) | |
| parent | 4986044fd3bce877247e425374b47967775081a8 (diff) | |
Merge "Fix window leak and receiver leak. Bug: 2520143 and Bug: 2517390"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/Activity.java | 5 | ||||
| -rw-r--r-- | core/java/android/app/SearchDialog.java | 33 |
2 files changed, 27 insertions, 11 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 3c5a1c7cfb45..a9623917f757 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1320,6 +1320,11 @@ public class Activity extends ContextThemeWrapper } mManagedCursors.clear(); } + + // Close any open search dialog + if (mSearchManager != null) { + mSearchManager.stopSearch(); + } } /** diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index add99d78eda2..0ebe3ac09cad 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -132,6 +132,15 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // Last known IME options value for the search edit text. private int mSearchAutoCompleteImeOptions; + private BroadcastReceiver mConfChangeListener = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) { + onConfigurationChanged(); + } + } + }; + /** * Constructor - fires it up and makes it look like the search UI. * @@ -149,16 +158,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mSearchManager = searchManager; - IntentFilter filter = new IntentFilter(); - filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); - context.registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) { - onConfigurationChanged(); - } - } - }, filter); } /** @@ -297,10 +296,20 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS show(); } updateUI(); - + return true; } + @Override + public void onStart() { + super.onStart(); + + // Register a listener for configuration change events. + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); + getContext().registerReceiver(mConfChangeListener, filter); + } + /** * The search dialog is being dismissed, so handle all of the local shutdown operations. * @@ -311,6 +320,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS public void onStop() { super.onStop(); + getContext().unregisterReceiver(mConfChangeListener); + closeSuggestionsAdapter(); // dump extra memory we're hanging on to |
