使用PopWindow遇到的BadTokenException: Unable to add window is not valid; is your activity r
来源:互联网 发布:数据监测中心方案 编辑:程序博客网 时间:2024/04/29 20:26
具体报错如下:
FATAL EXCEPTION: main
android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4051c0e0 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:558)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:433)
at android.app.Dialog.show(Dialog.java:265)
at net.reecam.CameraSearch$3.onClick(CameraSearch.java:103)
at android.view.View.performClick(View.java:2532)
at android.view.View$PerformClick.run(View.java:9308)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
FATAL EXCEPTION: main
android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4051c0e0 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:558)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:433)
at android.app.Dialog.show(Dialog.java:265)
at net.reecam.CameraSearch$3.onClick(CameraSearch.java:103)
at android.view.View.performClick(View.java:2532)
at android.view.View$PerformClick.run(View.java:9308)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
问题分析:
PopupWindow和AlertDialog都无法在OnCreate()方法中进行显示
解决方法:
通过事件触发(Button等),从而进行显示控件功能。
PS:
PopWindow使用注意事项
1、当屏幕显示PopupWindow对话框时,他并没有获得焦点,你需要通过PopupWindow的
setFocusable(true)方法实现获取焦点。
2、如何使得单击其他非PopupWindow的方法,使得PopupWindow消失的方法
popupWindow.setBackgroundDrawable(new BitmapDrawable());
0 0
- 使用PopWindow遇到的BadTokenException: Unable to add window is not valid; is your activity r
- view.WindowManager$BadTokenException: Unable to add window…is not valid; is your activity running?
- PopWindow Unable to add window -- token null is not valid; is your activity running
- BadTokenException:Unable to add window …… is your activity running?is not valid; is your activity ru
- android.view.WindowManager$BadTokenException:Unable to add window --token is not valid; is your acti
- AsyncTask 与 对话框显示 view.WindowManager$BadTokenException: Unable to add window…is not valid; is your a
- Anroid 异常:Unable to add window …… is not valid; is your activity running?
- Unable to add window is not valid; is your activity running?
- Unable to add window — token android.os.BinderProxy is not valid; is your activity running?
- PopupWindow出现Unable to add window -- token null is not valid; is your activity running?
- Anroid 异常:Unable to add window 。。is not valid; is your activity running?
- Anroid 异常:Unable to add window …… is not valid; is your activity running?
- Unable to add window -- token android.os.BinderProxy@XXX is not valid; is your activity running?
- Unable to add window -- token android.os.BinderProxy@xxx is not valid; is your activity running
- Unable to add window — token android.os.BinderProxy is not valid; is your activity running?
- Unable to add window -- token null is not valid; is your activity running?
- Unable to add window --token is not valid; is your activity running?
- - Unable to add window -- token null is not valid; is your activity running?
- 在js中制作div弹出框
- Single Number
- SQLite Editor
- WebDriver实现
- linux--历史命令:history
- 使用PopWindow遇到的BadTokenException: Unable to add window is not valid; is your activity r
- HDU 4925 Apple Tree 找呀找规律
- C++ 模板方法
- radius源码下载
- poj 2155 第一天学树状数组,还没怎么搞清楚二维的区间更新单点查询
- POJ 2337 欧拉回路+欧拉路径+判断欧拉回路和路径
- NSMutableArray
- Server 数据库巡检脚本
- Spring笔记(5)------依赖注入