23 July 2016

How to fix android.view.WindowManager$BadTokenException: Unable to add window -- token null

STORY:
If your app crash with this error:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
.. while while it tries to display dialog ,then it mean you provide wrong context
                     
SOLUTION

replace:
AlertDialog.Builder alertBox = new AlertDialog.Builder(getApplicationContext());
with
AlertDialog.Builder alertBox = new AlertDialog.Builder(AppLauncher.this);

No comments:

Post a Comment