/**
* Listing 5-21: Dynamically toggling manifest Receivers
*/
ComponentName myReceiverName = new ComponentName(this, MyReceiver.class);
PackageManager pm = getPackageManager();
// Enable a manifest receiver
pm.setComponentEnabledSetting(myReceiverName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
// Disable a manifest receiver
pm.setComponentEnabledSetting(myReceiverName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
【BroadcastReceiver】在运行时管理Manifest Receiver
最新推荐文章于 2018-06-20 10:28:10 发布