java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@450b2f48 异常处理

晕死的错误,改了半天也没想到是这样的原因,基础正要呀。。。

先看一下警告信息:

07-07 08:32:19.540: WARN/WindowManager(74): Failed looking up window
07-07 08:32:19.540: WARN/WindowManager(74): java.lang.IllegalArgumentException:Requested window android.os.BinderProxy@450b2f48 does not exist
07-07 08:32:19.540: WARN/WindowManager(74):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9293)
07-07 08:32:19.540: WARN/WindowManager(74):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9284)
07-07 08:32:19.540: WARN/WindowManager(74):     at com.android.server.WindowManagerService.relayoutWindow(WindowManagerService.java:2364)
07-07 08:32:19.540: WARN/WindowManager(74):     at com.android.server.WindowManagerService$Session.relayout(WindowManagerService.java:6782)
07-07 08:32:19.540: WARN/WindowManager(74):     at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:117)
07-07 08:32:19.540: WARN/WindowManager(74):     at com.android.server.WindowManagerService$Session.onTransact(WindowManagerService.java:6743)
07-07 08:32:19.540: WARN/WindowManager(74):     at android.os.Binder.execTransact(Binder.java:288)
07-07 08:32:19.540: WARN/WindowManager(74):     atdalvik.system.NativeStart.run(Native Method)

Java代码如下:

public class MyActivity extends Activity implements Runnable {
	private static final int SEARCH_APP = 0;
	private ProgressDialog pd;
	private Handler mHandler = new Handler() {
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			if (msg.what == SEARCH_APP) {
				pd.dismiss();
            }
		}
	};

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.show_app_grid);

		pd = ProgressDialog.show(this, "请稍候···", "正在搜索你所安装的程序···");
		Thread t = new Thread(this);
		t.start();

	}

	public void run() {
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		mHandler.sendEmptyMessage(SEARCH_APP);
	}
}

原因是语句Thread t = new Thread()没有谢参数,因为在实现多线时如果是实现的Runnable接口,必要Thread t = new Thread(Runnable runnable),所以把语句Thread t = new Thread()修改为Thread t = new Thread(this)运行就正确了。

    原文作者:liuyiming_
    原文地址: https://blog.csdn.net/liuyiming_/article/details/7726579
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞