错误:Unable to add window -- token null is not for an application
2017-09-22 15:07
429 查看
今天开发中遇到问题:android.view.WindowManager$BadTokenException: Unable to add window – token null is not for an application
后来原因是因为创建Dialog时传递的Context类型问题。
getApplicationContext()获得的context为整个应用的上下文,而对于AlertDialog来说,是需要依赖一个View,而View是对应于Activity的。所以,一般传入应该为Acitivity.this。
后来原因是因为创建Dialog时传递的Context类型问题。
getApplicationContext()获得的context为整个应用的上下文,而对于AlertDialog来说,是需要依赖一个View,而View是对应于Activity的。所以,一般传入应该为Acitivity.this。
相关文章推荐
- android AlertDialog显示错误 Unable to add window token null is not for an application解决办法
- Unable to add window -- token null is not for an application错误的解决方法 android开发
- AlertDialog显示错误 Unable to add window token null is not for an application
- Unable to add window -- token null is not for an application错误的解决方法
- AlertDialog显示错误 Unable to add window token null is not for an application
- Unable to add window -- token null is not for an application错误的解决方法 android开发
- AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- Dialog Unable to add window -- token null is not for an application错误的解决方法
- AlertDialog显示错误 Unable to add window token null is not for an application
- 关于 Unable to add window -- token null is not for an application 错误的解决方法
- 在创建一个Dialog时,发生的错误: Unable to add window -- token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- Unable to add window -- token null is not for an application错误的解决方法
- Unable to add window -- token null is not for an application错误的解决方法
- android AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- Unable to add window -- token null is not for an application
- 【转】WindowManager$BadTokenException: Unable to add window -- token null is not for an application