InputDispatcher: MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

log日志如下:

10-27 22:03:38.190    3338-4531/? I/HwPowerMonitor.PowerExceptionObservable﹕ unhandled onEvent actionID: 3002
10-27 22:03:38.190    3338-4531/? I/HwPowerMonitor.LogCacheSend﹕ wifi or 3G connected
10-27 22:03:38.190    3338-4531/? I/HwPowerMonitor.LogCacheSend﹕ do not need send, lastSendTime: 1445950166380, startTime:1431785366789, currTime: 1445954618199
10-27 22:03:40.090  26164-26164/? I/Process﹕ Sending signal. PID: 26164 SIG: 9
10-27 22:03:40.140    2855-3001/? W/InputDispatcher﹕ channel '42998888 com.zhym.myapp/com.zhym.myapp.function.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
10-27 22:03:40.140    2855-3001/? E/InputDispatcher﹕ channel '42998888 com.zhym.myapp/com.zhym.myapp.function.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-27 22:03:40.140    2855-3420/? W/InputDispatcher﹕ Attempted to unregister already unregistered input channel '42998888 com.zhym.myapp/com.zhym.myapp.function.MainActivity (server)'
10-27 22:03:40.250    6259-6259/? I/wpa_supplicant﹕ wlan0: HEART-BEAT-ACK: 296
10-27 22:03:40.410    3300-3311/? W/Binder﹕ Caught a RuntimeException from the binder stub implementation.
    java.lang.NullPointerException
            at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
            at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
            at android.os.Binder.execTransact(Binder.java:404)
            at dalvik.system.NativeStart.run(Native Method)
10-27 22:03:40.410    3300-3311/? W/System.err﹕ java.lang.NullPointerException
10-27 22:03:40.410    3300-3311/? W/System.err﹕ at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
10-27 22:03:40.410    3300-3311/? W/System.err﹕ at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
10-27 22:03:40.410    3300-3311/? W/System.err﹕ at android.os.Binder.execTransact(Binder.java:404)
10-27 22:03:40.410    3300-3311/? W/System.err﹕ at dalvik.system.NativeStart.run(Native Method)
10-27 22:03:40.450    2855-2870/? I/ActivityManager﹕ Displayed com.zhym.myapp/.function.MainActivity: +304ms
10-27 22:03:46.350    2855-2855/? W/HwScreenOnProximityLock﹕ releaseLock: return because sensor listener is held = false
10-27 22:03:46.350    3056-3056/? I/KeyguardFingerprint.Validation﹕ start

相关代码如下:

task.getData(new LoadDataFromServer.DataCallback() {
            @Override
            public void onDataCallback(JSONObject data) {
              try {                
              int code = data.getInteger("1");
//                int code = data.getInteger("code");
                if(code == 1) {
                    Toast.makeText(UserInfoActivity.this, "更新成功1...",Toast.LENGTH_SHORT).show();
                } else if(code == 2) {
                    Toast.makeText(UserInfoActivity.this, "更新成功2...",Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(UserInfoActivity.this, "更新失败!!!...",Toast.LENGTH_SHORT).show();
                }

              } catch (JSONException e) {
                  Toast.makeText(UserInfoActivity.this, "数据解析错误...",Toast.LENGTH_SHORT).show();
                  e.printStackTrace();
              }
            }
//            @Override
//            public void onDataCallback(String returnData) {
//                String result = returnData;
//                Log.e("------------UserInfoActivity:updateAvatarInServer:onDataCallback----","--------result="+result+"---------");
//
//            }
        });

 
  


错误原因:在这个回调接口中,参数data是键值形式,它的实际值是(“1”,“1“),而我却用int code = data.getIneger("code")即key="code"来查找其对应的数据,但是实际值中并没有key="code"的这个键。

代码修改:把code换成”1“即可。即换成data中真正存在的键才能找到对应的值。

感悟:出现bug,如果编程环境没问题,那就是程序本身的问题,多把设计的程序的逻辑关系理一理,就能找到问题所在了

你可能感兴趣的:(Android)