bug_ _java.lang.IllegalArgumentException: View not attached to window manager 2
今天遇到一个很奇特的问题,当用户设置了PIN码,在锁屏界面正常解锁PIN码后,进入Launcher时显示com.android.phone 已停止运行。一开始猜想会不会是解锁PIN码的时候处理导致了Phone进程报错,通过log分析找到了问题的大概原因:
- AndroidRuntime: java.lang.IllegalArgumentException: View not attached to window manager
- AndroidRuntime: at com.android.stk.StkDialogActivity$4.onClick(StkDialogActivity.java:188)
这是开机识别到SIM卡之后弹出的STK对话框。那为什么会报com.android.phone已停止运行呢?
经过以上分析,我们可以大致猜测是因为STK引起的问题,既然是STK的问题那为什么会报phone的错误呢?如果是phone的错误那么从log中应该可以检索到phone相关的问题,为什么没有呢?那么我们接下来一一解答这些问题。
(1). 为什么报错com.android.phone已停止运行?
(2). 为什么会报View not attached to window manager错误?
(3). 为什么STKDialogActivity会被"杀掉"?
- onCreate
- onResume - mbSendResp[false], sim id: 0
- ... ...省略部分
- onSaveInstanceState
- onPause, sim id: 0
- ... ...省略部分
- onDestroy-
- onCreate
- ... ...省略部分
- onRestoreInstanceState - [com.android.internal.telephony.cat.TextMessage@41fe7d80]
- onResume - mbSendResp[false], sim id: 0
(4). 在STKDialogActivity被杀掉时,Dialog存在么?
- WindowManager: Activity com.android.stk.StkDialogActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41fea228 V.E..... R.....ID 0,0-1026,433} that was originally added here
- WindowManager: android.view.WindowLeaked: Activity com.android.stk.StkDialogActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41fea228 V.E..... R.....ID 0,0-1026,433} that was originally added here
- WindowManager: at android.view.ViewRootImpl.<init>(ViewRootImpl.java:409)
- WindowManager: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:218)
- WindowManager: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
- WindowManager: at android.app.Dialog.show(Dialog.java:281)
- WindowManager: at android.app.AlertDialog$Builder.show(AlertDialog.java:951)
- WindowManager: at com.android.stk.StkDialogActivity.onCreate(StkDialogActivity.java:192)
- WindowManager: at android.app.Activity.performCreate(Activity.java:5122)
- WindowManager: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
- WindowManager: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
- WindowManager: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
- WindowManager: at android.app.ActivityThread.access$600(ActivityThread.java:156)
这里的WindowManager报错是什么意思呢?这段log是WindowManager抛出的error错误,当我们的Dialog还没有dismiss时,如果此时该Activity被销毁了,那么就会出现以上错误,提示窗口泄漏(leaked window)。这里自己也做了一个实验,写一个demo,在Activity的onCreate方法中显示一个Dialog,然后直接调用finish方法。代码大致如下:
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- AlertDialog.Builder info = new Builder(this);
- info.setTitle("Dialog").setPositiveButton("OK", null).setMessage("This is a Dialog");;
- info.show();
- finish();
- }
直接将此程序run到模拟器或者真机上,查看log我们就能看到leaked window的报错信息。因此这也证明了前面我们的假设,即StkActivity在被销毁时,其所依附的Dialog是存在的。
(5). 如何解决这个问题呢?
1. 使用Activity自带的Dialog控制方法
2. 限制Dialog的生命周期
bug_ _java.lang.IllegalArgumentException: View not attached to window manager 2的更多相关文章
- bug_ _java.lang.IllegalArgumentException: View not attached to window manager
============= 1 view not attached to window manager 转自:http://hi.baidu.com/spare_h/blog/item/7fa3e ...
- 关于java.lang.IllegalArgumentException: View not attached to window manager 错误的分析
今天遇到一个很奇特的问题,当用户设置了PIN码,在锁屏界面正常解锁PIN码后,进入Launcher时显示com.android.phone 已停止运行.一开始猜想会不会是解锁PIN码的时候处理导致了P ...
- java.lang.IllegalArgumentException: View not attached to window manager
公司项目线上bug: java.lang.IllegalArgumentException: View not attached to window manager at android.view.W ...
- decorview that was originally added here or java.lang.IllegalArgumentException: View not attached to window manager
使用Dialog的时候,没少出现下面这两个报错 12-11 17:47:49.776: E/WindowManager(11461): android.view.WindowLeaked: Activ ...
- Android中 View not attached to window manager错误的解决办法
前几日出现这样一个Bug是一个RuntimeException,详细信息是这样子的:java.lang.IllegalArgumentException: View not attached to w ...
- View not attached to window manager
java.lang.IllegalArgumentException: View not attached to window manager 在用ProgressDialog的时候,任务结束后Dis ...
- View not attached to window manager crash 的解决办法
View not attached to window manager crash 的解决办法 转自:http://stackoverflow.com/questions/22924825/view- ...
- 关于dialog引起的 java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView not attached to window manager 错误的分析
在跑Monkey测试的时候出现了一个比较特别的问题,先来看看Log: // CRASH: com.meizu.media.painter (pid 12491) // Short Msg: java. ...
- view not attached to windows manager与This Toast was not created with Toast.makeText()
http://blog.sina.com.cn/s/blog_474928c90100x871.html public class Ex04_1Activity extends Activ ...
随机推荐
- InputStreamReader和OutputStreamWriter
public class ClientSocket { public static void main(String args[]) { String host = "1 ...
- Docker基础技术
http://coolshell.cn/articles/17200.html http://coolshell.cn/articles/17061.html http://coolshell.cn/ ...
- dir:一行代码,提取出所有视频文件名称及路径
某次,部门接到一个任务,要求对公司现有的视频文件资料做一个统计整理分类的工作. 领导召集开会,问:两周时间够用吗? 统计整理分类工作的第一步骤是把视频文件名称来源类别信息录入到 excel 表格中,才 ...
- CentOS6.4-RMAN定时任务备份 on 11GR2
1.rman备份脚本位置: /home/oracle ./scripts/ ./bin -----存放rman脚本 ./log ...
- C++ const使用详解
1.const常量和宏常量const int max=100;#define max 100;const常量相对宏常量有两个有点:1)有类型安全检查2)占用内存空间少 2.const变量在内存中的位置 ...
- EDIUS设置自定义输出的方法
在做后期视频剪辑时,往往根据需求,需要输出不同分辨率格式的视频文件,那在EDIUS中,如何自定义输出设置,使之符合自己的需要呢?下面小编就来详细讲讲EDIUS自定义输出的一二事吧. 当剪辑完影片,设置 ...
- windows下android环境的搭建:完成后添加android其他版本
JDK: jdk-6u10-rc2-bin-b32-windows-i586-p-12_sep_2008.exe Eclipse:Eclipse3.7.1 Android sdk:android-sd ...
- Jenkins入门系列之
Jenkins入门系列之——00答疑解惑 Jenkins进阶系列之——11修改Jenkins用户的密码 Jenkins进阶系列之——12详解Jenkins节点配置 Jenkins进阶系列之——13修改 ...
- 移动端H5页面的设计稿尺寸大小规范-转载自http://www.chinaz.com/design/2015/1103/465670.shtml
机屏幕尺寸,设计稿应该按照哪一个尺寸作为标准尺寸.现在已经有2K分辨率的手机屏幕了,设计稿是不是也要把宽高跟着最大分辨率来设计.显然不是. 请注意:(以下所有讨论内容和规范均将viewport设定为c ...
- CGI相关概念
common gateway interface 通用网关接口 可以让客户端从浏览器向执行在服务器上的程序请求数据.CGI描述了客户端和服务器程序之间传输数据的一种标准. 编程语言perl是一种被广泛 ...