温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android怎么解决AlertDialog对话框异常

发布时间:2020-06-03 11:54:45 来源:亿速云 阅读:310 作者:Leah 栏目:移动开发

Android怎么解决AlertDialog对话框异常?这个问题可能是我们日常工作经遇见到的。通过这个问题,希望你能收获更多。如果你不看答案,不知道是否有把握回答这个问题?让我们来试试。

错误信息先沾上来:

java.lang.RuntimeException: Unable to start activity ComponentInfo


java.lang.RuntimeException: Unable to start activity ComponentInfo


java.lang.RuntimeException: Unable to start activity ComponentInfo


android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@422dc6e8 is not valid; is your activity running?

at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:768)


Andrdoid用仿iphone的TabBar是用TabHost+ActivityGroup来解决的,里面用View堆栈的形式加载 Activity,在里面的Activity用AlertDialog对话框是,报异常:android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@422dc6e8 is not valid; is your activity running?

把AlertDialog里面的context:xxxActivity.this 改为::“xxxActivity.this..getParent()”就搞定!

看完上述内容,你们对Android解决AlertDialog对话框异常的方法有进一步的了解吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI