View not attached to window manager crash 的解决办法
View not attached to window manager crash 的解决办法
转自:http://stackoverflow.com/questions/22924825/view-not-attached-to-window-manager-crash
down voteaccepted
+50
|
How to reproduce the bug:
The Android OS will destroy an activity as soon as it is hidden. When How to fix it:
|
public class YourActivity extends Activity {
<...>
private void showProgressDialog() {
if (pDialog == null) {
pDialog = new ProgressDialog(StartActivity.this);
pDialog.setMessage("Loading. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
}
pDialog.show();
}
private void dismissProgressDialog() {
if (pDialog != null && pDialog.isShowing()) {
pDialog.dismiss();
}
}
@Override
protected void onDestroy() {
dismissProgressDialog();
super.onDestroy();
}
class LoadAllProducts extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
showProgressDialog();
}
/**
* getting All products from url
* */
protected String doInBackground(String... args)
{
doMoreStuff("internet");
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url)
{
if (YourActivity.this.isDestroyed()) { // or call isFinishing() if min sdk version < 17
return;
}
dismissProgressDialog();
something(note);
}
}
}
View not attached to window manager crash 的解决办法的更多相关文章
- Android中 View not attached to window manager错误的解决办法
前几日出现这样一个Bug是一个RuntimeException,详细信息是这样子的:java.lang.IllegalArgumentException: View not attached to w ...
- 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 ...
- bug_ _java.lang.IllegalArgumentException: View not attached to window manager 2
今天遇到一个很奇特的问题,当用户设置了PIN码,在锁屏界面正常解锁PIN码后,进入Launcher时显示com.android.phone 已停止运行.一开始猜想会不会是解锁PIN码的时候处理导致了P ...
- 关于java.lang.IllegalArgumentException: View not attached to window manager 错误的分析
今天遇到一个很奇特的问题,当用户设置了PIN码,在锁屏界面正常解锁PIN码后,进入Launcher时显示com.android.phone 已停止运行.一开始猜想会不会是解锁PIN码的时候处理导致了P ...
- View not attached to window manager
java.lang.IllegalArgumentException: View not attached to window manager 在用ProgressDialog的时候,任务结束后Dis ...
- 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 ...
- 关于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 ...
随机推荐
- 2015第16周六学习java建议
学习Java 建议: 尽量用 google 查找技术资料. 有问题在 stackoverflow 找找,大部分都已经有人回答. 多看官方的技术文档. ibm developerworkers 的文章质 ...
- jdbc连接数据库工具类
import java.lang.reflect.Field; import java.sql.Connection; import java.sql.DriverManager; import ja ...
- 基于阿里云server搭建SVNserver
基于阿里云server搭建SVNserver 本系列文章由ex_net(张建波)编写,转载请注明出处. http://blog.csdn.net/ex_net/article/details/8577 ...
- TCP三次握手的过程
三次握手 下图就是wireshark抓包工具抓获的TCP连接建立的三次握手过程: http://www.cnblogs.com/hnrainll/archive/2011/10/14/2212415. ...
- 解决数据库Operation not allowed when innodb_forced_recovery > 0
解决数据库Operation not allowed when innodb_forced_recovery > 0 请修改my.cnf innodb_force_recovery = 1 修改 ...
- Asp.net开发常用的51个非常实用的代码
1.弹出对话框.点击转向指定页面 Code: Response.Write("<script>window.alert('该会员没有提交申请,请重新提交!')</scrip ...
- css-文字
<!DOCTYPE html>CSS2-文字 <style>div{ /*文字*/ font-size:120px; /*文字大小*/ font-family:Arial,'方 ...
- Dreamwaver 使用root用户连接不上远程服务器
我用dreamweaver连接远程服务,开始用的是root用户登录的,但是连接不上.网上查了一下,解决教程非常复杂,我就不列出来了. 后来我想了一下,之前我有连接过.我感觉可能是用户的问题,于是我在远 ...
- 一次$.getJSON不执行的记录
别人的代码,拿过来调,发现修改功能都不能用,修改时通过ajax发json获取数据的,看chrome开发者工具发现有发送数据,也有返回值: 发起请求并获取数据,发现回调函数不执行! $.getJSON( ...
- git configuration
git的配置文件由section名和变量名组成: [user] name = abc emial = example.com []里面的user就是section名,section只能由字母,数字,- ...