1:广播接收里面处理的时间不能超过5s
2:自定义的广播与系统广播不能共用同一个广播接收器,受权限限制
静态注册:
<receiver android:name=
".BootReceiver"
android:label=
"@string/app_name"
>
<intent-filter>
<action android:name=
"android.intent.action.PACKAGE_ADDED"
/>
<action android:name=
"android.intent.action.PACKAGE_REMOVED"
/>
<data android:scheme=
"package"
/>
</intent-filter>
</receiver>
动态注册:
IntentFilter filter =newIntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme(
"package"
);
registerReceiver(receiver, filter);