txusballesteros / bubbles-for-android

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.
Apache License 2.0
1.48k stars 281 forks source link

App force closed #33

Closed fayazara closed 4 years ago

fayazara commented 7 years ago

Hello,

I have to recreate the exact same app in the repository here, however when I open it, it force closes and throws an error

android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@1454e05 -- permission denied for window type 2006 at android.view.ViewRootImpl.setView(ViewRootImpl.java:702) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93) at com.txusballesteros.bubbles.BubblesService$2.run(BubblesService.java:120) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

I have attached the Main Activity code in the Doc, please assist.

Regards, Fayaz New Microsoft Word Document (2).docx

lyfebackup commented 7 years ago

@fayazara I'm having the exact same problem. Was really looking forward to using this library.

lyfebackup commented 7 years ago

@fayazara I found the issue. Android M requires a permission this lib needs to be called at runtime. Here's how to go about it: `private static final int OVERLAY_REQUEST_CODE = 2033; // ID of the permission request.

// Add this to wherever you're initializing your bubbleManager, mine is in onCreate @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //... // Check build to see if we're running M if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Check to see if permission has been granted. if (!Settings.canDrawOverlays(this)) { // If it hasn't, start an intent to request the permission Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); startActivityForResult(intent, OVERLAY_REQUEST_CODE); } else { // Otherwise, if the permission has been granted, initialize the bubblesManager bubblesManager = new BubblesManager.Builder(this).setTrashLayout(R.layout.bubble_trash).build(); bubblesManager.initialize(); } } }

// Finally, have a callback ready when permission is granted @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if (requestCode == OVERLAY_REQUEST_CODE) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (Settings.canDrawOverlays(this)) {
                BubbleLayout bubbleView = (BubbleLayout) LayoutInflater.from(Lyfe.this).inflate(R.layout.bubble_user, null);

                bubblesManager = new BubblesManager.Builder(this).build();
                bubblesManager.initialize();
                bubblesManager.addBubble(bubbleView, 60, 20);
            }
        }
    }

}` Hope that helps! Shout if you need a full example.

fayazara commented 7 years ago

Hi,

Thank you so much for the response, I have added the permission, and it works. However, when I try to delete the bubble, it doesn't close, just stays, I might have missed out something, could you kindly help me out, amateur at coding as well as android. Thanks.

Here's my git https://github.com/fayazara/Energia

Thanks, Fayaz

abdelrahmana commented 4 years ago

i have been working on this issue and i fixed it please go a head to my modification and clone it https://github.com/abdelrahmana/bubble-Android- cheers