问题描述
- 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。
请教下是不是这段代码有错误呢?
解决方案
应该在发消息的代码中,每次发消息的时候,都要new 一个 Message对象,或者调用hander的obtainMessage
解决方案二:
http://blog.csdn.net/songjunyan/article/details/41803131
解决方案三:
是不是把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);
}
时间: 2024-11-05 16:32:42