是由于有activity时依附于另一个activity的,当被依附的activity
产生错误的时候,该activity没有了靠山而产生错误(或者是调用了一个已经被finish()的activity)。一般在创建
alertdialog.builder是很容易见到。
对于这个错误
还没有根本的解决办法,唯一的办法就是改变该activity依附于另一activity的事实,将其放入另一activity。
Android利用ActivityGroup加载子Activity,子Activity调用对话框,弹出:
ERROR/AndroidRuntime(10104): Caused by: android.view.WindowManager$BadTokenException: Unable
to add window -- token android.app.LocalActivityManager$LocalActivityRecord@45a58ee0 is not valid; is your activity running?
原因分析:
因为new对话框的时候,参数content 指定成了this,即指向当前子Activity的content。但子Activity是动态创建的,不能保证一直存在。其父Activity的content是稳定存在的,所以有下面的解决办法。
解决办法:
将content替换为getParent()即可。
分享到:
相关推荐
k8s Unable to connect to the server: x509: certificate is valid for问题解决
shardingsphere 4.1.1 SQLFeatureNotSupportedException: isValid 解决办法 替换如下两个JAR sharding-jdbc-orchestration-4.1.1.jar sharding-jdbc-core-4.1.1.jar 参考下下面链接,更改源码 ...
错误spring boot上传文件错误The temporary upload location [/tmp/tomcat.******/work/Tomcat/localhost/ROOT] is not valid
PopupWindow组件的使用问题,PopupWindow是一个阻塞对话框,如果你直接在Activity创建的方法中显示它,则会报错:android.view.WindowManager$BadTokenException:Unable to add window -- token null is not valid;...
【AIX】3004-314 Password was recently used and is not valid for reuse
自己编写的 非常简单和基本的 希望能够帮助到朋友们
An abbreviated form of the WISC-R: Is it valid? 426 Psycholoyy in the Schools, October, 19;7', Vo1. 14, No. 4. In addition, in the Hamm. et al., study when the WISC-R was administered first the ...
在keil开发过程中,有的情况下文件必须是utf8格式,如果不是utf8格式,编译出来运行起来是乱码,但是keil默认情况下编译不支持utf8格式的文件。网上到处的说法是增加no-multibyte-chars选项,但是作为初学者,不知道...
这是一个 Go 语言用来读写新的 Excel 文件格式 —— XSLX 的开发包。读示例:package main import ( "fmt" ...) func main() { excelFileName := "/home/tealeg/foo.xlsx" xlFile, err := xlsx.Open...
Reference is not valid while using hyperlinks on excel files in windows
layer是一款近年来备受青睐的web弹层组件,她具备全方位的解决方案,致力于服务各水平段的开发人员,您的页面会轻松地拥有丰富友好的操作体验
ERROR/AndroidRuntime(888): android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRoot$W@44ef1b68 is not valid; is your activity running? 报错的意思大概就是说...
解决使用wsdl生成java客户端报错:java.lang.reflect.invocationtargetexception的方法之一
IE不支持JSON对象的问题,看代码示例: if(typeof (JSON) == 'undefined'){ $.getScript("plug-in/tools/json2.js"); } </script>
NULL 博文链接:https://tianjun309.iteye.com/blog/854393
the string was not recognized as a valid Datetime. there is a unknown word starting at index 9
python库。 资源全名:is_valid_postgres_column_name-0.0.1-py3-none-any.whl
postgis-2.0.dll": %1 is not a valid Win32 application解决方案-附件资源
解决运行parasoft jtest 错误: 错误: No valid license (MachineId: WIN32-6c7b9803)