Unable to add window -- token null is not for an application

Android开发遇到这个错误:

ERROR/AndroidRuntime(247): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

原因:

在传context的时候用了getApplicationContext()

解决办法

传context的时候使用Activity.this

你可能感兴趣的:(Unable to add window -- token null is not for an application)