title: Keep showing popupWindow when back button of keyboard is pressed
body: <p>I am working on an Android application and I've designed a popupWindow to show some view by replacing a soft keyboard in an activity. The popupWindow contains a searchView. When I click on a button, it shows the popupWindow and the soft keyboard gets hidden. Now when the searchView in the popupWindow gets focus, I call the method:</p>
  
  <blockquote>
    <p>popupWindow.setFocusable(true)</p>
  </blockquote>
  
  <p>To show keyboard so that users can start typing in searchView. When the searchView is in focus and the soft keyboard is open, then pressing the back key closes both the searchView and the popupWindow as well.</p>
  
  <p>To solve this issue, I created a <strong>custom searchView</strong> and overrode the method <strong>dispatchKeyEventPreIme</strong> in this as below.</p>
  
  <pre><code>public class CustomSearchView extends SearchView {
  
      Context context;
      AppConstant mAppConst;
  
      public CustomSearchView(Context context, AttributeSet attrs) {
          super(context, attrs);
          this.context = context;
      }
  
  
      @Override
      public boolean dispatchKeyEventPreIme(KeyEvent event) {
  
         if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
             clearFocus();
          }
          return super.dispatchKeyEventPreIme(event);
      }
  }
  </code></pre>
  
  <p>I have cleared the focus from the searchView when the back button is pressed, but I don't know how can I prevent the popupWindow from closing.</p>
  
  <p><a href="https://i.stack.imgur.com/wkWSc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wkWSc.png" alt="enter image description here"></a></p>