关闭

Android simplest intent broadcast

92人阅读 评论(0) 收藏 举报

1) define broadcast receiver:

    private BroadcastReceiver mBroadCastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

        }

    }

 

2) register receiver

        IntentFilter filter2 = new IntentFilter();
        filter2.addAction("xx.xxx.xxx.xxx");
        context.registerReceiver(mBroadCastReceiver, filter2);

 

3) send broadcast

          intent.setAction("xx.xxx.xxx.xxx");
          intent.putExtra("actionType", '');
          mCtx.sendBroadcast(intent);

 

This way is simplest broadcast usage. It can broadcast a intent to anywhere, including process running by system, root or other app user. we don't modify AndroidManifest.xml anyway. Of cause it has no permission management.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:188次
    • 积分:11
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档