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