0

I'm using this library.

and I know it can run on android M, but for some reason it crashes everytime with my project.

I tried researching and adding permission SYSTEM_ALERT_WINDOW (even tho it's not required) and i'm stuck.

Anyone know why it crashes?

private void addViewToWindow(final BubbleBaseLayout view) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
crashes here >>> getWindowManager().addView(view, view.getViewParams());
}
});
}

android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@ce82da -- permission denied for this window type

NSNoob
  • 5,548
  • 6
  • 41
  • 54
Shaul
  • 211
  • 1
  • 4
  • 18

1 Answers1

0

It was a permission issue, just not the usual way(as in manifest). This is the solution i found on a different thread:

if (!Settings.canDrawOverlays(this)) {
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                        Uri.parse("package:" + getPackageName()));
                startActivityForResult(intent, 3);

Run this through your activity, prior to creation of bubbles.

Shaul
  • 211
  • 1
  • 4
  • 18