您的位置:首页 > 移动开发

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

2016-09-29 10:44 369 查看
android.view.WindowManager$BadTokenException:Unable to add window -- token null is not for anapplication
分析:

问题在于newAlertDialog.Builder(Context),虽然这里的参数是AlertDialog.Builder(Contextcontext)

但我们不能使用getApplicationContext()获得的Context,而必须使用Activity的Context对象,因为只有一个Activity才能添加一个窗体。

解决方法:

将new AlertDialog.Builder(Contextcontext)中的参数用Activity的Context对象即可.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Unable to add window