android Unable to add window -- token null is not for an application
来源:互联网 发布:计算机二级java考试 编辑:程序博客网 时间:2024/06/06 02:02
代码中出现如下错误:
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对象即可,但我写Dialog的地方是fragement,起初我用的是getActivity();但是还是有这个问题,不是毕现的,最后改为getContext();
0 0
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- android AlertDialog显示错误 Unable to add window token null is not for an application
- android AlertDialog显示错误 Unable to add window token null is not for an application
- android debug:Unable to add window -- token null is not for an application
- android Unable to add window -- token null is not for an application
- Unable to add window -- token null is not for an application错误的解决方法 android开发
- android报错——Unable to add window -- token null is not for an application
- WindowManager$BadTokenException: 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 的解决办法
- 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 Studio:如何使用Android Studio与夜神模拟器开发调试
- Spring 3整合Quartz 2实现定时任务一:常规整合
- hdu-1253-胜利大逃亡(bfs)
- 安装debian7.8后的初始工作
- Android R.java文件丢失的问题
- android Unable to add window -- token null is not for an application
- android 时间分发
- Linux命令
- vi/vim 光标移动命令
- Win7可变对象头结构之InfoMask解析
- iOS 获取手机的型号,系统版本,软件名称,软件版本
- appstore和腾讯的Entitlements
- java多线程之CAS
- 在 SQL Server 2008 中新建用户登录并指定该用户的数据库