赞
踩
1.在 AndroidManifest.xml 中删除 相关receiver的配置标签
2.手动的receiver代码
- public class LReceiver extends BroadcastReceiver {
-
-
- //这里为何要用 intent.action. ?
- public static final String ACTION = "com.example.kfk.lbroadcastreceiver.intent.action.LReceiver";
- // public static final String ACTION = "com.example.kfk.lbroadcastreceiver.LReceiver";//也可以
- public LReceiver() {
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
-
- System.out.println("接收器L 收到了消息:" + intent.getStringExtra("msg"));
- }
- }
2.手动注册
- <span style="white-space:pre"> </span>receiver = new LReceiver();
- IntentFilter filter = new IntentFilter(LReceiver.ACTION);
- filter.setPriority(1);
- registerReceiver(receiver,filter);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。