

So I looked at Android docs on Activity and discovered a very useful method – isFinishing() which is called by Android when Activity enters finishing stage: be it explicit finish() call or activity clean up made by Android. Here is how you can change the color of the status bar using the new tStatusBarColor method introduced in API level 21. However, according to Google Play console, exception occurred very often and seemed very consistent.Īfter doing some research I found out that it is possible for my app to try notifying the user while being in the background (device screen is locked, app is sent to background with home button). Android Lollipop brought with it the ability to change the color of status bar in your app for a more immersive user experience and in tune with Google’s Material Design Guidelines. I could not reproduce it myself: I tried every device I had and every type of emulator I could think of, but no luck, the app worked just fine. This exception occurred while app was trying to notify user from the background thread by opening a Dialog.

$BadTokenException: Unable to add window - token android.os.BinderProxy is not valid is your activity running?Īt (ViewRoot.java: 452 )Īt (WindowManagerImpl.java: 283 )Īt (WindowManagerImpl.java: 193 )Īt $CompatModeWrapper.addView (WindowManagerImpl.java: 118 )Īt $LocalWindowManager.addView (Window.java: 532 )Īt (Dialog.java: 269 )Ī$BadTokenException: Unable to add window - token is not valid is your activity running?Īt (ViewRoot.java:452)Īt (WindowManagerImpl.java:283)Īt (WindowManagerImpl.java:193)Īt $CompatModeWrapper.addView(WindowManagerImpl.java:118)Īt $LocalWindowManager.addView(Window.java:532)Īt (Dialog.java:269)
