Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permission denied for window type 2006 #41

Open
pavlomelnyk opened this issue Oct 2, 2018 · 2 comments
Open

permission denied for window type 2006 #41

pavlomelnyk opened this issue Oct 2, 2018 · 2 comments

Comments

@pavlomelnyk
Copy link

Hello.
Help needed please.

W/System.err: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$WEx@ab0bdc9 -- permission denied for window type 2006
W/System.err: at android.view.ViewRootImpl.setView(ViewRootImpl.java:829)
W/System.err: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:368)
W/System.err: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
W/System.err: at com.androidhiddencamera.HiddenCameraService.addPreView(HiddenCameraService.java:125)
W/System.err: at com.androidhiddencamera.HiddenCameraService.startCamera(HiddenCameraService.java:82)
W/System.err: at com.pins.infinity.services.CaptureImageService.onStartCommand(CaptureImageService.java:98)
W/System.err: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3609)
W/System.err: at android.app.ActivityThread.-wrap20(Unknown Source:0)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1717)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:105)
W/System.err: at android.os.Looper.loop(Looper.java:164)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6710)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

Library version 1.3.2

So it only shows up on GL g6 with android 8.1.1. I guess its related to
"For Android API level of 8.0.0, you should use
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
instead of LayoutParams.TYPE_TOAST or TYPE_APPLICATION_PANEL or SYSTEM_ALERT."
from
https://stackoverflow.com/questions/32224452/android-unable-to-add-window-permission-denied-for-this-window-type

@pavlomelnyk
Copy link
Author

Ok I see you fixed that at 1.3.4
"/**
* Add camera preview to the root of the activity layout.
*
* @return {@link CameraPreview} that was added to the view.
*/
private CameraPreview addPreView() {
//create fake camera view
CameraPreview cameraSourceCameraPreview = new CameraPreview(this, this);
cameraSourceCameraPreview.setLayoutParams(new ViewGroup
.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(1, 1,
            Build.VERSION.SDK_INT < Build.VERSION_CODES.O ?
                    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY :
                    WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);

    mWindowManager.addView(cameraSourceCameraPreview, params);
    return cameraSourceCameraPreview;
}

"

@InadullaevMakhmudjon
Copy link

Thank you this worked me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants