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

android O new issue #39

Open
NullPoint-A opened this issue Aug 21, 2017 · 12 comments
Open

android O new issue #39

NullPoint-A opened this issue Aug 21, 2017 · 12 comments

Comments

@NullPoint-A
Copy link

android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@2557df6 -- permission denied for window type 2006
at android.view.ViewRootImpl.setView(ViewRootImpl.java:789)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:92)
at com.txusballesteros.bubbles.BubblesService$2.run(BubblesService.java:120)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

app targetSdkVersion 26

help me.. T.T

@xiaoxuanwang
Copy link

For android API > 22, it need the users' permission to allow the app to put on top of other apps. For API <=22, the system grant the permission automatically.

@NullPoint-A
Copy link
Author

TYPE_PHONE, TYPE_SYSTEM_OVERLAY can not be used when targeting OREO.
Use TYPE_APPLICATION_OVERLAY instead. need to change the library.

BubblesService.java -> buildLayoutParamsForBubble() , buildLayoutParamsForTrash()

@NullPoint-A
Copy link
Author

@fifisamy
Copy link

fifisamy commented Feb 6, 2018

ihave this problem also with android o what is the solution

@SpamhaterAlex
Copy link

I have the same problem.

@SpamhaterAlex
Copy link

I suppose the only way is to override the methods, but dont know, how to implement them

@jwgibanez
Copy link

I am also having the same issue. Has anyone found a viable solution?

@lxknvlk
Copy link

lxknvlk commented Aug 14, 2018

Same problem here. BubblesManager initialization crashes app, despite having needed permission and Settings.canDrawOverlays(getApplicationContext()) returns true

@harmskhosa
Copy link

If I'm not mistaken, @NullPoint-A comment is the best solution. The library needs to be updated to use TYPE_APPLICATION_OVERLAY instead when setting the params for each layout (the bubble and the trash). But this change seems pretty simple. For example, for the bubble, the new code in the BubblesService class should look like:

private WindowManager.LayoutParams buildLayoutParamsForBubble(int x, int y) {
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams. TYPE_APPLICATION_OVERLAY,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSPARENT);
        params.gravity = Gravity.TOP | Gravity.START;
        params.x = x;
        params.y = y;
        return params;
    }

I'll send a pull request if I have time...

@appspell
Copy link

Please check this out
#47

@harmskhosa
Copy link

@appspell lgtm

@MyCentreBucket
Copy link

This worked for me.

final WindowManager.LayoutParams myParams = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                        | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                        | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                PixelFormat.TRANSLUCENT
        );


        if (Build.VERSION.SDK_INT >= 23) {
            if (!Settings.canDrawOverlays(this)) {
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                startActivity(intent);
                return;
            } else {
                WindowManager windowManager = getWindowManager();
                windowManager.addView(bubbleView, myParams);
            }
        } else {
            WindowManager windowManager = getWindowManager();
            windowManager.addView(bubbleView, myParams);
        }

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

9 participants