【Android】Android 4.0 无法接收开机广播的问题
前面的文章 Android 开机广播的使用 中 已经提到Android的开机启动,但是在Android 4.0 有时可以接收到开机启动广播,有时却不可以。经过分析发现,如果应用程序安装上始终没有被打开过,那么在Android启动时,该应用无法接收到开机启动 广播android.permission.RECEIVE_BOOT_COMPLETED。
原来在Android 3.1的更新文档中已经做了说明。
下面是引自Android官方API说明,地址 http://developer.android.com/about/versions/android-3.1.html#launchcontrols
原文如下
Launch controls on stopped applications
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.
Note that an application's stopped state is not the same as an Activity's stopped state. The system manages those two stopped states separately.
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.
When neither or both of these flags is defined in an intent, the default behavior is to include filters of stopped applications in the list of potential targets.
Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications. A background service or application can override this behavior by adding theFLAG_INCLUDE_STOPPED_PACKAGES flag to broadcast intents that should be allowed to activate stopped 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).
翻译如下
从Android 3.1开始,系统的软件包管理器跟踪处于停止状态(stopped state)的应用程序,提供了一种控制其启动后台进程和其他应用程序方式。
需要注意的是应用程序的停止状态(stopped state)和Activity的停止状态是不一样的。该系统可以分别管理这两种停止状态。
该平台定义了两个新的Intent的Flag,让发送者指定的意图是否应该被允许激活停止的应用程序的组件。
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.排除停止的应用程序列表中的。
当两个Flag都不设置或都设置的时候,默认操作是FLAG_INCLUDE_STOPPED_PACKAGES。
请注意,系统向所有的Intent的广播添加了FLAG_EXCLUDE_STOPPED_PACKAGES标志。它这样做是为了防止广播无意中的或
不必要地开启组件的stoppped应用程序的后台服务。后台服务或应用程序可以通过向广播Intent添加
FLAG_INCLUDE_STOPPED_PACKAGES标志来唤醒处于停止状态(stopped state)的应用程序。
应用程序处于停止状态情况有两种,一种是他们是第一次安装,但尚未启动,另一种是在管理应用程序中由用户手动停止。
简单的说,就是防止开机启动恶意程序,优化启动。经过验证发现,系统级的应用程序是可以接收到开机启动广播的。
转自 http://blog.csdn.net/leilu2008/article/details/8933869
【Android】Android 4.0 无法接收开机广播的问题的更多相关文章
- Android 进程常驻(5)----开机广播的简单守护以及总结
这是一个轻量级的库,配置几行代码.就能够实如今android上实现进程常驻,也就是在系统强杀下,以及360获取root权限下.clean master获取root权限下都无法杀死进程 支持系统2.3到 ...
- 【Android】15.0 第15章 广播和通知—本章示例主界面
分类:C#.Android.VS2015: 创建日期:2016-02-28 一.简介 广播(Broadcast):其功能类似于收音机的广播,你只要调到那个台(只要在接收的类中注册了要接收的广播),就能 ...
- Android 4.0及以上版本接收开机广播BOOT_COMPLETED、开机自启动服务
1.BootCompletedReceiver.Java文件 public class BootCompletedReceiver extends BroadcastReceiver { @Overr ...
- Android的有序广播和无序广播(解决安卓8.0版本之后有序广播的接收问题)
前言 Google从Android8.0版本开始,对在清单文件中静态注册广播做了限制. *** 特殊广播(动态注册广播接收者) 说:有序广播和无序广播之前,咱们先来说下Android中一些特殊的广播如 ...
- 解决android3.0版本号以上应用接收不到开机广播问题
如今是2014-07-16 下午15:27. 好久没写过东西,突然间灵感喷发想写点东西(事实上是刚刚弄好了一个棘手的问题,自豪中..呵呵呵呵 我牛掰).废话不多说,进入正题. 不知道你们又没有碰到这问 ...
- Android 进程常驻----开机广播的简单守护以及总结
这是一个轻量级的库,配置几行代码,就可以实现在Android上实现进程常驻,也就是在系统强杀下,以及360获取root权限下,clean master获取root权限下都无法杀死进程 支持系统2.3到 ...
- Android开机广播
有些时候我们常常需要某个程序开机运行.在这个时候我们就需要监听系统的开机广播,然后启动我们的程序即可. 不多说 直接上代码: public class BootReceiver extends Bro ...
- android 发送自定义广播以及接收自定义广播
发送自定义广播程序: 布局文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...
- MIUI7,Android版本5.0.2,一个程序发送自定义广播,另一个程序没有接收到
对照<第一行代码——Android>进行学习,第五章中说到广播包的相关知识,前面获取广播等程序例程都可以跑的通,但是在5.3.2节中,程序A发送自定义广播,并接收自定义广播,同时程序B也接 ...
随机推荐
- 使用flowable 6.1.2 REST API 运行请假审批流程
一.下载 flowable rest war 包 http://download.csdn.net/detail/teamlet/9913312 二.部署 复制flowable REST.war到To ...
- 《Drools7.0.0.Final规则引擎教程》第4章 4.2 auto-focus
auto-focus 在agenda-group章节,我们知道想要让AgendaGroup下的规则被执行,需要在代码中显式的设置group获得焦点.而此属性可配合agenda-group使用,代替代码 ...
- 记一次诡异的网络故障排除 - tpc_tw_recycle参数引起的网络故障
一.故障现象 我们团队访问腾讯云上部署的测试环境中的Web系统A时,偶尔会出现类似于网络闪断的情况,浏览器卡很久没有反应,最终报Connection Timeout. 不过奇怪的是,当团队中的某个人无 ...
- 【python】socket
UDP udp_server.py from datetime import datetime import socket server_address = ('localhost', 6789) m ...
- HDU - 5936: Difference(暴力:中途相遇法)
Little Ruins is playing a number game, first he chooses two positive integers yy and KK and calculat ...
- hbase filter 简介
一.基本介绍 1.FilterList代表一个过滤器列表 FilterList.Operator.MUST_PASS_ALL --> 取交集 相当一and操作 FilterList.Operat ...
- Array数组(PHP学习)
什么是数组? 答:就是一组数. 数组的创建: <?php $Arr = array('姓名'=>'张三','身高'=>'174','家乡'=>'上海'); print_r($A ...
- Win7旗舰版一直显示检查更新的问题
最近部门机器从新安装win7 64位 旗舰版之后,每次检查更新,都会一直卡在检查更新的界面过不去,上网搜了一下,看到了网友提供的解决办法, 测试了一下,果然可以.记录下来,以备后用: 到微软官网去下载 ...
- CString 中的SpanIncluding 和SpanExcluding 用法
SpanIncluding 简单的理解就是提取包含在指定串中的一个子串 MSDN上的备注说:从左边的第一个字符开始查找与给定串相等的字符,如果没有则返回空的串,反之,继续查找,到结束. 例子方便理解 ...
- juc线程池原理(一):总体介绍
概要 线程池类图 线程池的类图如下: 1. Executor 它是"执行者"接口,它是来执行任务的.准确的说,Executor提供了execute()接口来执行已提交的 Runna ...