当前位置:   article > 正文

BroadcastReceiver(二)手动注册注销receiver_crtix receiver注销

crtix receiver注销

1.在 AndroidManifest.xml 中删除 相关receiver的配置标签

2.手动的receiver代码 

  1. public class LReceiver extends BroadcastReceiver {
  2. //这里为何要用 intent.action. ?
  3. public static final String ACTION = "com.example.kfk.lbroadcastreceiver.intent.action.LReceiver";
  4. // public static final String ACTION = "com.example.kfk.lbroadcastreceiver.LReceiver";//也可以
  5. public LReceiver() {
  6. }
  7. @Override
  8. public void onReceive(Context context, Intent intent) {
  9. System.out.println("接收器L 收到了消息:" + intent.getStringExtra("msg"));
  10. }
  11. }


2.手动注册

  1. <span style="white-space:pre"> </span>receiver = new LReceiver();
  2.         IntentFilter filter = new IntentFilter(LReceiver.ACTION);
  3.         filter.setPriority(1);
  4.         registerReceiver(receiver,filter);
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/738370
推荐阅读
相关标签
  

闽ICP备14008679号