java.lang.IllegalArgumentException: Requested window [email protected] 异常处理

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

先看一下警告信息:

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 [email protected] 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] view plaincopy

  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. public void onCreate(Bundle savedInstanceState) {
  13. super.onCreate(savedInstanceState);
  14. setContentView(R.layout.show_app_grid);
  15. pd = ProgressDialog.show(this, "请稍候···", "正在搜索你所安装的程序···");
  16. Thread t = new Thread(this);
  17. t.start();
  18. }
  19. public void run() {
  20. try {
  21. Thread.sleep(3000);
  22. } catch (InterruptedException e) {
  23. e.printStackTrace();
  24. }
  25. mHandler.sendEmptyMessage(SEARCH_APP);
  26. }
  27. }

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

java.lang.IllegalArgumentException: Requested window [email protected] 异常处理

时间: 2024-10-09 09:33:11

java.lang.IllegalArgumentException: Requested window [email protected] 异常处理的相关文章

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: Activity TestActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42204800 V.E..... R.....I. 0,0-640,164} that was originally

java.lang.IllegalArgumentException: View not attached to window manager

公司项目线上bug: java.lang.IllegalArgumentException: View not attached to window manager at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:406) at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:308) at androi

关于dialog引起的 java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView not attached to window manager 错误的分析

在跑Monkey测试的时候出现了一个比较特别的问题,先来看看Log: 1 // CRASH: com.meizu.media.painter (pid 12491) 2 3 // Short Msg: java.lang.IllegalArgumentException 4 5 // Long Msg: java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{2

[zhuan]Android 异常处理:java.lang.IllegalArgumentException(...contains a path separator)

http://blog.csdn.net/alex_zhuang/article/details/7340901 对以下错误: Java.lang.RuntimeException: java.lang.IllegalArgumentException: File /data/data/com.alex.datasave/files/user.txt contains a path separator 原先代码: fis = this.context.openFileInput("/data/d

Android 异常处理:java.lang.IllegalArgumentException(..

对以下错误: java.lang.RuntimeException: java.lang.IllegalArgumentException: File /data/data/com.alex.datasave/files/user.txt contains a path separator 原先代码: fis = this.context.openFileInput("/data/data/com.alex.datasave/files/user.txt"); 正确代码: File f

java.lang.IllegalArgumentException: Registered more than one instance with the same objectName

java.lang.IllegalArgumentException: Registered more than one instance with the same objectName <May 25, 2017 12:29:19 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING> <May 25, 2017 12:29:19

Android Studio:Unable to add window [email&#160;protected] -- permission denied for this window 第一行代码

学习<第一行代码>的时候,出现的错误. java.lang.RuntimeException: Unable to start receiver com.example.sevenun.littledemo.receiver.ForceOfflineReceiver: android.view.WindowManager$BadTokenException: Unable to add window [email protected] -- permission denied for this

错误:java.lang.IllegalArgumentException: Receiver not registered

Caused by: java.lang.IllegalArgumentException: Receiver not registered: [email protected] at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:861) at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1352) at android.content.Co

java.lang.IllegalArgumentException: Receiver not registered

错误提示:java.lang.IllegalArgumentException: Receiver not registered. 顾名思义就是Receiver没有被注册,这是由于取消了没有注册的Receiver导致的错误. 我们使用Receiver时必须保证注册(register)和反注册(unregister)成对出现. 遇到这种问题时,你需要检查下自己代码中注册和反注册的代码,看下是否存在多次调用unregister的时候. 很多时候都是想当然认为会那样,但是程序中可能有我们未预料的出口,