You need to call setBackgroundDrawable() on PopupWindow and set the background to not null . This sounds strange, but if background not configured for something on your PopupWindow , then it will not be able to detect events from Activity , such as a touch outside the window or a click on the back button.
I had the same problem just a few days ago. I will try to find the SO answer, where someone explains why this is so, but it may take me a bit. At the same time, try it, it should work.
Found
I did not have the opportunity to test it, but you can try to add keyEventListener and do something like this
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) {
and add setOutsideTouchable(true) to your PopupWindow object and call update() on it. If this does not work, you may need to just leave the back button disabled when the popup appears and add your own Button to the window. I did not find anything else that allows you to select events with the button pressed.
source share