Android go 自定义静态广播接收不到的问题

1. 清单文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
        package="com.android.phone"
        coreApp="true"        
        android:sharedUserLabel="@string/phoneAppLabel"
    android:sharedUserId="android.uid.phone">
    <application android:name="PhoneApp">
        <receiver android:name="com.mediatek.settings.MyBroadcastReceiver"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.mediatek.provider.action.MY_BROADCAST"/>
            </intent-filter>
        </receiver>
    </application>
</manifest>

2. 哪些app是系统app呢?有两类:
    一类是uid为android.uid.system, android.uid.phone, android.uid.log, android.uid.nfc, android.uid.bluetooth, android.uid.shell的app是系统app。
 另一类是指定目录中的app是系统app,“指定目录”包括/vendor/overlay,/system/framework,/system/priv-app,/system/app,/vendor/app,/oem/app。

3. manifest中protected-broadcast 的一些细节 :    请参考

4. 发送广播时带上包名,即该广播注册的清单文件所对应的包名:package="com.android.phone"
   1) 使用setPackage,intent.setPackage("com.android.phone");//参数是包名

   2) 使用ComponentName,参数1是包名,参数2是自定义广播的路径

    Intent intent = new Intent("com.mediatek.provider.action.MY_BROADCAST");
    intent.setPackage("com.android.phone");
    //intent.setComponent(new ComponentName("com.android.phone", "com.mediatek.settings.MyBroadcastReceiver"));  
    sendBroadcast(intent); 

5. 参考
https://blog.csdn.net/kongqwesd12/article/details/78998151

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值