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.view.WindowManager$BadTokenException in Nougat #2

Open
abhinashpati opened this issue Aug 1, 2017 · 10 comments
Open

android.view.WindowManager$BadTokenException in Nougat #2

abhinashpati opened this issue Aug 1, 2017 · 10 comments
Labels

Comments

@abhinashpati
Copy link

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:679)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at greco.lorenzo.com.lgsnackbar.core.LGSnackbarPresenter.show(LGSnackbarPresenter.java:51)
at greco.lorenzo.com.lgsnackbar.core.LGSnackbar.show(LGSnackbar.java:90)
at greco.lorenzo.com.lgsnackbar.LGSnackbarManager.showSnackbar(LGSnackbarManager.java:91)
at greco.lorenzo.com.lgsnackbar.LGSnackbarManager.show(LGSnackbarManager.java:86)
at greco.lorenzo.com.lgsnackbar.LGSnackbarManager.show(LGSnackbarManager.java:70)

I'm only getting this on Android 7 or above devices.
Below 7, it's working fine.

@loregr loregr added the bug label Aug 5, 2017
@loregr
Copy link
Owner

loregr commented Aug 5, 2017

Thanks for reporting. I'll investigate on it.

@nontravis
Copy link

I have the same problem.

@loregr
Copy link
Owner

loregr commented Aug 19, 2017

I am not able to replicate it, I've just run the example in the repo and it is working on a Nougat device. Could you please check if the example is working for you?

@akexorcist
Copy link

akexorcist commented Aug 19, 2017

screenshot_20170819-193244

It look like the problem is about the solution that you use in this library. The library add the view to window manager directly so it doesn't minimized when user minimized the app. That's different with Snackbar library from Android Design Support Library because they use layout in each activity to add the Snackbar's view (Snackbar at findSuitableParent(View view)).

I think this can make the problem occur in some device firmware. As I tested with example in the repo, it work fine on Samsung Galaxy S8 and Moto Z but won't work with Android One

@alfco333
Copy link

I have investigated a little on this topic and it seems some devices have to ask for this permission: SYSTEM_ALERT_WINDOW, but it can only be achieved through the Settings, I've used this intent for the task: new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + packageName)); but some devices do not respond to the intent.

@jsimoes84
Copy link

Hey there. Did you manage to fix this bug? I really like this project, but can't use it from android 7 above. Can you fix it?

@aruljey
Copy link

aruljey commented Sep 25, 2018

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?

Hi loregr

Could you please solve this problem? I need this library to work with my APP.

@thiyagesh6m
Copy link

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? same problem brother please resolve it ... as of now any solution there...

@GlaucioOliveira
Copy link

Well, it's 2020 and this same problem continues... No fix to this?

@Hendriyawan
Copy link

this bug no fix yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants