Open NullPoint-A opened 7 years ago
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.
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()
ihave this problem also with android o what is the solution
I have the same problem.
I suppose the only way is to override the methods, but dont know, how to implement them
I am also having the same issue. Has anyone found a viable solution?
Same problem here. BubblesManager initialization crashes app, despite having needed permission and Settings.canDrawOverlays(getApplicationContext()) returns true
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...
Please check this out https://github.com/txusballesteros/bubbles-for-android/pull/47
@appspell lgtm
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);
}
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