写了这么一个程序: 代码中只包含一个BroadcastReceiver, 监听开机广播, 然后静态注册在AndroidManifest.
碰到这么一个问题: 上述Receiver死活不触发.
找到这么一个解释: 软件必须要运行一次才能接收到开机广播的,这是谷歌在android高版本推出的安全机制
官方是这么说的(详见http://developer.android.com/about/versions/android-3.1.html):
Starting from Android 3.1, the system's package manager keeps track of applications that are in a stopped state and provides a means of controlling their launch from background processes and other applications.
Applications are in a stopped state when they are first installed but are not yet launched and when they are manually stopped by the user (in Manage Applications).
The platform defines two new intent flags that let a sender specify whether the Intent should be allowed to activate components in stopped application.
§FLAG_INCLUDE_STOPPED_PACKAGES — Include intent filters of stopped applications in the list of potential targets to resolve against.
§FLAG_EXCLUDE_STOPPED_PACKAGES — Exclude intent filters of stopped applications from the list of potential targets.
Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents.
总的来说, 就是自Android 3.1之后, 所有新安装但未被执行过的apk, 以及那些被用户强行停止的apk, 都会处于stopped状态.
这个状态下, apk中的广播接收器, 均处于未激活状态, 无法履行监听功能.
解决方案:
引入程序对其他apk的依赖, 即先依赖其他程序发送广播, 广播Intent中包含FLAG_INCLUDE_STOPPED_PACKAGES, 以激活该Receiver. 在不改变开机广播FLAG的前提下, 单apk实现"不经执行就监听开机广播"的功能, 暂时无解.
如果读者有较好的解决方案, 还望不吝赐教!
相关推荐
文档里面有android3.1和3.2SDK下载地址,及对应版本的google_api下载地址,并包含有相关安装说明。
android_3.1.apk
android sdk 3.1 android-sdk_r11-windows 只是个tool,sdk还要自己下载 手机开发平台 Google Android SDK 3.1 R11 Android eclipse插件安装: https://dl-ssl.google.com/Android/eclipse/ Android netBean插件安装:...
ACDSee 3.1 简体中文 绿色免安装版
Xamarin for Android 3.1.228 破解Android:复制mandroid.exe 到 %PROGRAMFILES(x86)%\MSBuild\Xamarin\Android 在cmd命令里切换到%PROGRAMFILES(x86)%\MSBuild\Xamarin\Android目录下运行以下命令进行注册: m...
Android 3.1支持Nvidia BSP内核包part002
Android 3.1支持Nvidia BSP内核包part001
android studio3.1下载 地址,文件里面是百度网盘下载地址
针对linux操作系统的 android sdk tool 只是个tool,sdk还要自己下载 手机开发平台 Google Android SDK 3.1 最终版 R11 Android eclipse插件安装: https://dl-ssl.google.com/Android/eclipse/ Android netBean插件...
下载后直接放到安装目录下的 /lib/ 中,重启软件即可。 原创地址、更多汉化包、问题反馈、免积分下载:http://www.pingfangx.com/xx/translation
TWINCAT V3.1安装及使用教程,利用TwinCAT3搭建EtherCAT主站环境流程
Apk安装包分析反编译工具。DIY的好助手。
eviews3.1安装
borland C3.1 含原始版和安装后的版本。 还有borland C3.1的安装方法。
Discuz!X3.1 全新安装图文教程 Discuz!X3.1 全新安装图文教程 Discuz!X3.1 全新安装图文教程
需要安装在android 2.2以上版本中,可以自动记录您的行走轨迹
1.RVCT3.1的安装 2.RVCT3.1兼容ADS1.2
windwos3.1安装镜像及安装方法文档
将压缩包解压后的内容 放入sdk\platforms\ 文件夹下即可
Apk改之理,版本3.1.