jmp-12 / SuperToasts

A library that extends the Android toast framework.
Apache License 2.0
2.67k stars 499 forks source link

I've got an error from android Kitkat 4.4.4 #88

Open irsalshabirin opened 8 years ago

irsalshabirin commented 8 years ago

in some device i've got an error like this :

Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@43093158 -- permission denied for this window type
       at android.view.ViewRootImpl.setView(ViewRootImpl.java:587)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:263)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
       at com.github.johnpersano.supertoasts.library.Toaster.displaySuperToast(Toaster.java:186)
       at com.github.johnpersano.supertoasts.library.Toaster.handleMessage(Toaster.java:136)
       at android.os.Handler.dispatchMessage(Handler.java:102)
.....

please help me, thankss

Farasy commented 8 years ago

Same here...

torinnguyen commented 8 years ago

i got it on a XiaoMi MI MAX running 6.0.1 Can't tell where and how exactly it happened. The stack trace I got is exactly as above.

mike-stetsenko commented 8 years ago

Xiaomi Mi4i, Android 5.0.2, MIUI 8 - the same error

android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@142544eb -- permission denied for this window type at android.view.ViewRootImpl.setView(ViewRootImpl.java:714) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:282) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at com.github.johnpersano.supertoasts.library.Toaster.displaySuperToast(Toaster.java:186) at com.github.johnpersano.supertoasts.library.Toaster.handleMessage(Toaster.java:136) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5546) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:967) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:163)

Farasy commented 8 years ago

May this helps:

http://stackoverflow.com/questions/7569937/unable-to-add-window-android-view-viewrootw44da9bc0-permission-denied-for-t

the-jedi-droid commented 7 years ago

True. MI devices plagued with this issue after a recent update.

ghost commented 7 years ago

It appears as though 6.0 now requires permission android.permission.SYSTEM_ALERT_WINDOW to add a view to the WindowManager. I'll investigate this further. I'm not sure what will happen to the SuperToast class then, I can't expect developers to add that permission for a simple toast message.

Farasy commented 7 years ago

Something new on this?

Could reproduce this error on Xiami Redmi 3 with Miui 8 but none of my other Android 5 / 6 devices.

alexeyvasilyev commented 7 years ago

Got the same issue with 1.3.4.1 with Xiaomi devices Redmi Note 3 (hennessy) running Android 5.0 and Mi 4c (libra) running Android 5.1.

Here is the stack:

android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@2ffb4010 -- permission denied for this window type at android.view.ViewRootImpl.setView(ViewRootImpl.java:714) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:282) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at com.github.johnpersano.supertoasts.ManagerSuperToast.displaySuperToast(ManagerSuperToast.java:189) at com.github.johnpersano.supertoasts.ManagerSuperToast.handleMessage(ManagerSuperToast.java:146) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5546) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:967) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

lockeb commented 7 years ago

Got the same issue also. Devices affected are:

OnePlus A3000 Xiaomi Redmi Note 3 Xiaomi Redmi Note 2 Xiaomi HM NOTE 1LTE

Any update on this?

Pe-te commented 7 years ago

running into this too on several different xiaomi devices!

evil question, but is the way supertoasts work different from the default android toasts? why does it need the overlay flag?

is there something in the code that can be made an option, so that it doesn't need the flag?

menion commented 7 years ago

Hello guys, I just want to inform, that one of my user just wrote me, that this issue seems to be solved in new version MIUI 8.1 (currently in 'dev' state). So let's wait on final version of MIUI rom.

sucese commented 7 years ago

Hey guys, I also get the question in my xiaomi phone, this maybe helps you. https://www.liaohuqiu.net/cn/posts/android-windows-manager/

PhilippeBoisney commented 7 years ago

Same weird issue... capture d ecran 2017-06-10 a 11 41 00

PhilippeBoisney commented 7 years ago

As this issue happens only with Xiaomi devices, I've created a temporary quick fix to avoid crashes:

private void showSafely(SuperToast superToast){
        if (!android.os.Build.MANUFACTURER.toLowerCase().contains("xiaomi")){ 
           superToast.show(); 
        }
 }