title: Popup window dismiss on outside touch not working
body: <p>Please check what I have tried so far before down voting for duplicate.<br>
  I am trying to dismiss the popup window on outside touch. I have tried every solution available but it is not working.  </p>
  
  <p>1st try :  </p>
  
  <pre><code>pwindo.setBackgroundDrawable(new BitmapDrawable());
              pwindo.setFocusable(true);
              pwindo.setOutsideTouchable(true);
  </code></pre>
  
  <p>2nd try :  </p>
  
  <pre><code>pwindo.setBackgroundDrawable(new ColorDrawable());
              pwindo.setFocusable(true);
              pwindo.setOutsideTouchable(true);
  </code></pre>
  
  <p>3rd try :  </p>
  
  <pre><code>pwindo.setBackgroundDrawable(new ColorDrawable());
              pwindo.setFocusable(true);
              pwindo.setOutsideTouchable(false);
  </code></pre>
  
  <p>4th try :  </p>
  
  <pre><code>        pwindo.setFocusable(true);
          pwindo.setOutsideTouchable(false);  
  </code></pre>
  
  <p>5th try :  </p>
  
  <pre><code>        pwindo.setOutsideTouchable(true);  
  </code></pre>
  
  <p>6th try :  </p>
  
  <pre><code>        pwindo.setOutsideTouchable(false);  
  </code></pre>
  
  <p>7th try :  </p>
  
  <pre><code>        pwindo.setFocusable(true);  
  </code></pre>
  
  <p>Nothing is working.  </p>
  
  <p><strong>Updated</strong>:  </p>
  
  <pre><code>public void addFlyout()
  {
      try {
          LayoutInflater inflater = TabActivity.this.getLayoutInflater();
          Display display = getWindowManager().getDefaultDisplay();
          Method mGetRawH = Display.class.getMethod("getRawHeight");
          Method mGetRawW = Display.class.getMethod("getRawWidth");
          int rawHeight = (Integer) mGetRawH.invoke(display);
          View view = inflater.inflate(R.layout.flyout_list_layout,
                  (ViewGroup) findViewById(R.id.flyoutLayoutList));
          Dialog dialog = new Dialog(TabActivity.this);
          pwindo = new PopupWindow(view, 340, rawHeight- actionBar.getHeight(), true);
          pwindo.showAtLocation(view, Gravity.RIGHT | Gravity.TOP, 0, actionBar.getHeight());
          pwindo.setBackgroundDrawable(new ColorDrawable(Color.RED));
         // pwindo.setTouchable(true);
          pwindo.setOutsideTouchable(true);
          pwindo.setTouchInterceptor(new View.OnTouchListener() {
              @Override public boolean onTouch(View v, MotionEvent event)
              {
  
                  if (event.getAction() == MotionEvent.ACTION_OUTSIDE)
                  {
                      pwindo.dismiss();
                      //Log.e(TAG, "some event happened outside window: action outside");
                      return true;
                  }
                 // Log.e(TAG, "some event happened outside window");
                  return false;
              }
          });
  
          listFlyout = (ListView) view.findViewById(R.id.list_slideList);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(TabActivity.this, R.layout.drawer_item, R.id.content, tabs);
          listFlyout.setAdapter(adapter);
      }
      catch (Exception ex)
      {
          ex.printStackTrace();
      }
  } 
  </code></pre>
  
  <p>And  </p>
  
  <pre><code>@Override
      public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
          // When the given tab is selected, switch to the corresponding page in
          // the ViewPager.
          try {
              if(tab.getPosition() == 4)
              {
                  addFlyout();
              }
              else
              mViewPager.setCurrentItem(tab.getPosition());
          }
          catch (Exception ex)
          {
              ex.printStackTrace();
          }
      }
  </code></pre>