I'm writing an application in which I'm adding a view to the WindowManager
using the following code:
private final FloatingBubbleView mBtn;
FloatingBubbleView iv = new FloatingBubbleView(context);
this.mBtn = iv;
this.mWm = (WindowManager) mAppContext.get().getSystemService(Context.WINDOW_SERVICE);
mWm.addView(mBtn, mLp);
the layout params configuration:
final WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.width = iv.getLayoutParams().width;
lp.height = iv.getLayoutParams().height;
lp.type = WindowManager.LayoutParams.TYPE_TOAST;
lp.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
lp.format = PixelFormat.TRANSLUCENT;
lp.gravity = Gravity.TOP | Gravity.LEFT;
lp.x = 0;
lp.y = 100;
On all operation systems prior to Android 7.0 (Nougat) this view sticks to the WindowManager
on switching an activity and I can still use it in the next opened activity.
On Nougat for some reason the views are removed from screen.
The question: Does anyone knows why this happens and how can I restore the previous behavior that I have on previous systems? does it has something to do with the new freeform window mode added in Nougat, described here:
Android Nougat’s freeform window mode: what it is and how developers can utilize it