runOnUiThread api 4.4错误

时间:2014-10-13 08:19:11

标签: java android eclipse android-4.4-kitkat

当我在Eclipse Emulator中的Android 4.4.2下运行此代码时,应用程序崩溃并找不到源代码错误。

在所有旧的Api版本(4.3等)上,代码运行没有任何问题。

出了什么问题?

public void begin_drawing(){
   running = true;     
   direct_thread = new Thread(){
          @Override
          public void run() {                                         
          while(running){

            try {
            Thread.sleep(500);                                                                                                                                              
            runOnUiThread(new Runnable() {
                 @Override
                 public void run() {
                 try {                    
                   int i = 0;                                                                                                                      
                 } catch (Exception e1) {    
                    e1.printStackTrace();
                 }  
                }
             });  

           } catch (Exception e) {
                e.printStackTrace();
           }
         }
      };
      };  
      direct_thread.start();      
  }

单步调试Line" Thread.sleep(500)"将执行,但" int i = 0;"不会打电话。

当我按F8(恢复)时,应用程序崩溃了。

汤姆

日志:

10-13 04:40:19.776: I/Maps.MyLocationOverlay(2276): Request updates from gps
10-13 04:40:19.796: I/SensorManager(2276): This application is using deprecated SensorManager API which will be removed someday.  Please consider switching to the new API.
10-13 04:40:20.526: I/MapActivity(2276): Handling network change notification:CONNECTED
10-13 04:40:20.536: E/MapActivity(2276): Couldn't get connection factory client
10-13 04:40:21.366: I/Choreographer(2276): Skipped 76 frames!  The application may be doing too much work on its main thread.
10-13 04:40:22.246: D/dalvikvm(2276): threadid=16: still suspended after undo (sc=1 dc=1)
10-13 04:40:22.356: D/dalvikvm(2276): GC_FOR_ALLOC freed 207K, 5% free 5461K/5736K, paused 69ms, total 165ms
10-13 04:40:22.716: A/PowerManager(2276): WakeLock finalized while still held: EL 77.0
10-13 04:40:23.336: A/PowerManager(2276): WakeLock finalized while still held: EL 77.0
10-13 04:40:25.926: W/System.err(2276): IOException processing: 26
10-13 04:40:25.926: W/System.err(2276): java.io.IOException: Server returned: 3
10-13 04:40:25.946: W/System.err(2276):     at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
10-13 04:40:25.946: W/System.err(2276):     at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
10-13 04:40:25.946: W/System.err(2276):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
10-13 04:40:25.956: W/System.err(2276):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
10-13 04:40:25.956: W/System.err(2276):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
10-13 04:40:25.966: W/System.err(2276):     at java.lang.Thread.run(Thread.java:841)
10-13 05:30:21.806: D/dalvikvm(2521): threadid=1: still suspended after undo (sc=1 dc=1)
10-13 05:30:22.346: D/dalvikvm(2521): threadid=1: still suspended after undo (sc=1 dc=1)

0 个答案:

没有答案