博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@450b2f48 异常处理
阅读量:4957 次
发布时间:2019-06-12

本文共 2145 字,大约阅读时间需要 7 分钟。

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

先看一下警告信息:

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代码如下:

 

[java] 
 
  1. public class MyActivity extends Activity implements Runnable {  
  2.     private static final int SEARCH_APP = 0;  
  3.     private ProgressDialog pd;  
  4.     private Handler mHandler = new Handler() {  
  5.         public void handleMessage(Message msg) {  
  6.             super.handleMessage(msg);  
  7.             if (msg.what == SEARCH_APP) {  
  8.                 pd.dismiss();  
  9.             }  
  10.         }  
  11.     };  
  12.   
  13.     public void onCreate(Bundle savedInstanceState) {  
  14.         super.onCreate(savedInstanceState);  
  15.         setContentView(R.layout.show_app_grid);  
  16.   
  17.         pd = ProgressDialog.show(this, "请稍候···", "正在搜索你所安装的程序···");  
  18.         Thread t = new Thread(this);  
  19.         t.start();  
  20.   
  21.     }  
  22.   
  23.     public void run() {  
  24.         try {  
  25.             Thread.sleep(3000);  
  26.         } catch (InterruptedException e) {  
  27.             e.printStackTrace();  
  28.         }  
  29.         mHandler.sendEmptyMessage(SEARCH_APP);  
  30.     }  
  31. }  

 

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

转载于:https://www.cnblogs.com/123ing/p/3912939.html

你可能感兴趣的文章