星空网 > 软件开发 > 操作系统

Service 广播 到Fragment

  //Fragment   public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);          System.out.println("oncreate");          //代码 注册 广播接收器     Receiver=new myReceiver();     IntentFilter filter=new IntentFilter();     filter.addAction("zcd.voicerobot");     getActivity().registerReceiver(Receiver,filter);         } //http://www.cnblogs.com/xiaobo-Linux/ 赵存档 QQ463431476  //内部类 广播接收 public class myReceiver extends BroadcastReceiver {    public void onReceive(Context context, Intent intent) {        String msg = intent.getStringExtra("message");     Toast.makeText(context, "广播已经接收", Toast.LENGTH_SHORT).show();    text.setText("我说:"+msg);     }}//service  public void UpdateGUI()   {         //broadcast      // service 通过广播来更新GUI      Intent intent=new Intent();      intent.putExtra("message",text);      intent.setAction("zcd.voicerobot");      sendBroadcast(intent);   }     

 




原标题:Service 广播 到Fragment

关键词:

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

中国到泰国的海运费是多少:https://www.goluckyvip.com/tag/89519.html
欧洲电商参谋:https://www.goluckyvip.com/tag/8952.html
泰国到中国海运快递:https://www.goluckyvip.com/tag/89520.html
天津海运泰国:https://www.goluckyvip.com/tag/89521.html
泰国到中国的海运费多少:https://www.goluckyvip.com/tag/89522.html
青岛到泰国海运:https://www.goluckyvip.com/tag/89523.html
深圳有没有比较好玩的景点 深圳有没有比较好玩的景点推荐一下:https://www.vstour.cn/a/366175.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流