2 llx2007 llx2007 于 2015.07.07 10:05 提问

android.util.AndroidRuntimeException

错误代码是:
07-07 08:34:19.693 11797-11809 E/JavaBinder﹕
*** Uncaught remote exception! (Exceptions are not yet supported
across processes.)
android.util.AndroidRuntimeException: { what=102 when=-22ms
obj=android.os.BinderProxy@4218d598 } This message is already in
use.

我现在不能很肯定是哪里的消息使用错误,请大神们帮我看看这段代码有没有错误

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_alarm);
        ctext = this;
        CfgLooper = Looper.myLooper();
        CfgHandler = new CfgHandler(CfgLooper); 
        show_alarm();
    }

  public  class CfgHandler extends Handler {
          public  CfgHandler(Looper looper) {
              super(looper);
          }
          public void handleMessage(Message msg) {
                    switch (msg.what) {
                        case comm_frame.SYS_CFG_RSP_FRM:
                            sys_cfg_rsp sys_cfg_rsp_info;
                            sys_cfg_rsp_info = (sys_cfg_rsp) msg.obj;
                            if (sys_cfg_rsp_info.child_type == comm_frame.SYS_CFG_TYPE_ALARM) {
                                new AlertDialog.Builder(ctext).setTitle("完成")
                                        .setMessage("设置成功")
                                        .setPositiveButton("确定", null).show();
                            }
                            break;
                        case comm_frame.EVENT_RSP_FRM:
                            event_info_rsp_class event_info_rsp;
                            event_info_rsp = (event_info_rsp_class) msg.obj;
                            comm_frame.invokeLongTimeToast(event_info_rsp, ctext);
                            break;
                    }
          }
     }

show_alarm()是4个check_box。
请教下是不是这段代码有错误呢?

3个回答

Arnold9009
Arnold9009   2015.07.07 10:27
已采纳

应该在发消息的代码中,每次发消息的时候,都要new 一个 Message对象,或者调用hander的obtainMessage

llx2007
llx2007 是改成这样么?
2 年多之前 回复
bdmh
bdmh   Ds   Rxr 2015.07.07 10:10
llx2007
llx2007 不想要连接,就像要点说明。
2 年多之前 回复
llx2007
llx2007 拜托敬业点好不。http://www.tuicool.com/articles/yAFfey
2 年多之前 回复
llx2007
llx2007   2015.07.07 10:39

是不是把switch里面改成这样

if(msg.what==comm_frame.SYS_CFG_RSP_FRM){
                  Message newMsg1 = AlarmCfgHandler.obtainMessage();
                  newMsg1.what = msg.what;
                  newMsg1.obj = msg.obj;
                  sys_cfg_rsp sys_cfg_rsp_info;
                  sys_cfg_rsp_info = (sys_cfg_rsp) newMsg1.obj;
                  if (sys_cfg_rsp_info.child_type == comm_frame.SYS_CFG_TYPE_ALARM) {

                      new AlertDialog.Builder(ctext).setTitle("完成")
                              .setMessage("报警设置成功")
                              .setPositiveButton("确定", null).show();
                  }
              }
 if(msg.what==comm_frame.EVENT_RSP_FRM){
                                        Message newMsg = CfgHandler.obtainMessage();
                    newMsg.what = msg.what;
                    newMsg.obj = msg.obj;
                  event_info_rsp_class event_info_rsp;
                  event_info_rsp = (event_info_rsp_class) newMsg.obj;
                  comm_frame.invokeLongTimeToast(event_info_rsp, ctext);
      }       

Csdn user default icon
上传中...
上传图片
插入图片