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

报错

Unable to add window android.view.ViewRootImpl$W@1a8910d – the specified window type 0 is not valid

解决办法

通过WindowManager给Window添加控件时,需要给LayoutParams指定Type

layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;

并且需要在AndroidManifest.xml中申请权限:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

你可能感兴趣的:(Android)