运行时动态注销在AndroidManifest.xml声明的BroadcastReceiver,Enabled and Disabled BroacastReceiver in Runtime
2013-10-11 15:24
483 查看
通常我们学到的动态注册和注销广播都是用了registerReceiver和unregisterReceiver但是对于在Manifest中注册的广播,unregisterReceiver却不起作用下面就介绍一个方法http://developer.android.com/reference/android/content/pm/PackageManager.html使用PackageManager中的setComponentEnabledSetting(ComponentName componentName,int newState, int flags)方法用法如下:
PackageManager pm = getPackageManager();ComponentName compName =new ComponentName(getApplicationContext(),YourReceiver.class);pm.setComponentEnabledSetting(compName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);参考文章:http://www.grokkingandroid.com/enabling-and-disabling-broadcastreceivers/http://stackoverflow.com/questions/5624470/enable-and-disable-a-broadcast-receiver
相关文章推荐
- Android运行时错误:Unable to find explicit activity,have you declared this activity in AndroidManifest.xml
- 解决Android Studio 或eclipse运行时出现Duplicate files copied in APK main/AndroidManifest.xml
- 解决Android Studio 或eclipse运行时出现Duplicate files copied in APK main/AndroidManifest.xml
- android.content.ActivityNotFoundException: Unable to find explicit activity class {...}; have you declared this activity in your AndroidManifest.xml?
- have you declared this activity in your AndroidManifest.xml?
- Android动态部署二:APK安装及AndroidManifest.xml解析流程分析
- androidmanifest.xml中声明相关权限
- Android开发之androidmanifest.xml中声明相关权限的说明
- Admob广告的android显示 "you must have AdActivity declared in AndroidManifest.xml with configChanges"
- AndroidManifest.xml中声明不同包中的Activity
- Multiple strings.xml files cause order and incomplete problems in android
- Run Android apps in Windows, OS X, Linux with Chrome (and a modified runtime)
- AndroidManifest.xml中声明不同包中的Activity
- The activity 'MainTwoActivity' is not declared in AndroidManifest.xml
- Android: Simplified source code for parsing and working with XML data and web services in Android
- AndroidManifest.xml中声明不同包中的Activity
- Access resource defined in theme and attrs.xml android
- android4.0 中设置网络出错com.android.settings.WirelessSettings没有在AndroidManifest.xml中声明
- android关于声明不同的activity在androidmanifest.xml里