星空网 > 软件开发 > ASP.net

android 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 handler ,message消息发送方式

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

谷歌seo前景:https://www.goluckyvip.com/tag/31819.html
告别黑科技:https://www.goluckyvip.com/tag/3182.html
谷歌seo软件:https://www.goluckyvip.com/tag/31820.html
谷歌seo实操:https://www.goluckyvip.com/tag/31821.html
谷歌seo视频课程:https://www.goluckyvip.com/tag/31822.html
谷歌seo收费:https://www.goluckyvip.com/tag/31823.html
中国有哪些著名的酒店品牌。:https://www.vstour.cn/a/411242.html
石象湖景区门票-石象湖景区门票优惠政策:https://www.vstour.cn/a/411243.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流