1

I have this error in just android 5.1

 Unable to add window android.view.ViewRootImpl$W@1df76e3 -- the specified window type is not valid

this is the code :

wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    params = new WindowManager.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSPARENT);
...
 wm.addView(relativeLayout, params);
Osama Raddad
  • 344
  • 3
  • 17

1 Answers1

0

add this permission in AndroidManifest.

android.permission.SYSTEM_ALERT_WINDOW

on API >= 23 see

artem
  • 15,245
  • 33
  • 109
  • 179
Osama Raddad
  • 344
  • 3
  • 17
  • 1
    I think you forgot the link - and looks like you copy/pasted the answer at http://stackoverflow.com/a/7570071/3847 – jklp Jul 01 '16 at 01:07