Android simplest intent broadcast

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.

阅读更多
文章标签: android filter system
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

Android simplest intent broadcast

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭