Android为TV端助力 handler ,message消息发送方式
1.Message msg = Message.obtain(mainHandler)
msg.obj=obj;//添加你需要附加上去的内容
msg.what = what;//what消息处理的类型
msg.sendToTarget();
获取消息:String msg2= (String)msg.obj;Log.i(TAG, "msg1::"+msg2);
2.Message msg = mHandler.obtainMessage(MSG_NOTICE_SUCCESS);
Bundle bundle = new Bundle();
bundle.putInt("id",id);
bundle.putLong("startTime",startTime);
bundle.putLong("endTime",endTime);
msg.setData(bundle);
msg.sendToTarget();
获取消息:Bundle data = msg.getData();
int id = data.getInt("id");
long effectiveTime = data.getLong("endtime");
3.当不需要传递数据时:
Handler.sendEmptyMessage(MSG_LOAD_ERROR);
4.发送延时消息:
Handler.sendEmptyMessageDelayed(MSG_DELAY_LOAD_REFRESH, 2000);
Android 为TV端助力