Merge "IllegalStateException fixed in print service settings" into lmp-mr1-dev
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index 49fd6df..e36e92c 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -137,6 +137,8 @@
 
     private boolean mServiceEnabled;
 
+    private SearchView mSearchView;
+
     @Override
     public void onResume() {
         super.onResume();
@@ -148,6 +150,9 @@
     @Override
     public void onPause() {
         mSettingsContentObserver.unregister(getContentResolver());
+        if (mSearchView != null) {
+            mSearchView.setOnQueryTextListener(null);
+        }
         super.onPause();
     }
 
@@ -408,8 +413,8 @@
 
         MenuItem searchItem = menu.findItem(R.id.print_menu_item_search);
         if (mServiceEnabled && mPrintersAdapter.getUnfilteredCount() > 0) {
-            SearchView searchView = (SearchView) searchItem.getActionView();
-            searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
+            mSearchView = (SearchView) searchItem.getActionView();
+            mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                 @Override
                 public boolean onQueryTextSubmit(String query) {
                     return true;
@@ -421,7 +426,7 @@
                     return true;
                 }
             });
-            searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
+            mSearchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
                 @Override
                 public void onViewAttachedToWindow(View view) {
                     if (AccessibilityManager.getInstance(getActivity()).isEnabled()) {