I created an activity which shows popup window. After the activity is stopped the following message is printed to log:
10-22 13:36:05.539: E/WindowManager(14865): android.view.WindowLeaked: Activity qnd.papaya.counter.gui.payment.PaymentActivity has leaked window android.widget.LinearLayout{430ac2a0 V.E..... ......I. 0,0-821,306} that was originally added here
10-22 13:36:05.539: E/WindowManager(14865): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:346)
10-22 13:36:05.539: E/WindowManager(14865): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
10-22 13:36:05.539: E/WindowManager(14865): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
10-22 13:36:05.539: E/WindowManager(14865): at android.widget.PopupWindow.invokePopup(PopupWindow.java:1019)
10-22 13:36:05.539: E/WindowManager(14865): at android.widget.PopupWindow.showAtLocation(PopupWindow.java:850)
10-22 13:36:05.539: E/WindowManager(14865): at android.widget.PopupWindow.showAtLocation(PopupWindow.java:814)
10-22 13:36:05.539: E/WindowManager(14865): at qnd.papaya.counter.controller.PaymentPanelController.showPaymentTypesPopup(PaymentPanelController.java:188)
10-22 13:36:05.539: E/WindowManager(14865): at qnd.papaya.counter.controller.PaymentPanelController.access$2(PaymentPanelController.java:159)
10-22 13:36:05.539: E/WindowManager(14865): at qnd.papaya.counter.controller.PaymentPanelController$3.onClick(PaymentPanelController.java:197)
10-22 13:36:05.539: E/WindowManager(14865): at android.view.View.performClick(View.java:4438)
10-22 13:36:05.539: E/WindowManager(14865): at android.view.View$PerformClick.run(View.java:18422)
10-22 13:36:05.539: E/WindowManager(14865): at android.os.Handler.handleCallback(Handler.java:733)
10-22 13:36:05.539: E/WindowManager(14865): at android.os.Handler.dispatchMessage(Handler.java:95)
10-22 13:36:05.539: E/WindowManager(14865): at android.os.Looper.loop(Looper.java:136)
10-22 13:36:05.539: E/WindowManager(14865): at android.app.ActivityThread.main(ActivityThread.java:5001)
10-22 13:36:05.539: E/WindowManager(14865): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 13:36:05.539: E/WindowManager(14865): at java.lang.reflect.Method.invoke(Method.java:515)
10-22 13:36:05.539: E/WindowManager(14865): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
10-22 13:36:05.539: E/WindowManager(14865): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
10-22 13:36:05.539: E/WindowManager(14865): at dalvik.system.NativeStart.main(Native Method)
Thus I would like to dismiss the popup in onPause() method of the activity.
Is there a way to get reference to all visible PopupWindows in activity? Something like:
@Override
protected void onPause() {
super.onPause();
findPopupWithTag("MY_POPUP").dismiss(); // <--- IS THERE A SIMILAR METHOD?
}
I don't want to keep explicit reference to popup to keep my code clean and simple...
Looks like this isn't possible
If you take look inside PopupWindow.invokePopup
method, it looks like this
private void invokePopup(WindowManager.LayoutParams p) {
...
mWindowManager.addView(mPopupView, p);
...
}
According this quiestion impossible find View
from WindowManager
by id