I am trying to create popup window on home screen when an floating image is clicked (using windowmanager
).
so while using layoutinflater
, I am not able to set a viewgroup
in the second argument as findviewbyId
is not recognised. so I kept null
. like below.
LayoutInflater inflater = (LayoutInflater) Floater.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.popup_for_floating_img,
null);
pwindo = new PopupWindow(layout, 300, 370, true);
pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
But when i click the floating image on home screen , it is giving below error message.
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
so please suggest me the way forward to get the popup on click.
I am trying for popup like if we enable floating widget in CLEAN MASTER app and click on floating broom image will give popup.