I am developing app for background videorecording ,thats why i used WindowManager,but it did not worked for me.gives following errors:
08-
Starting from marshmallow versions the permission approval is a little bit complex. So even after giving the above permission this issue is not resolved. Please see the following link.
Unable to add window android.view.ViewRoot$W@44da9bc0 -- permission denied for this window type
08-23 15:38:21.021: E/AndroidRuntime(4200): Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@418c0b68 -- permission denied for this window type
Problem: Permission missing in maifest file.
Solution:
Use following permission in AndroidManifest
.
android.permission.SYSTEM_ALERT_WINDOW
if your application apiLevel >= 19
, don't use
WindowManager.LayoutParams.TYPE_PHONE or WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
you can use
LayoutParams.TYPE_TOAST
or
TYPE_APPLICATION_PANEL
now my code for LayoutParams is like,
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_TOAST,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);