博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【Android】Android 4.0 无法接收开机广播的问题
阅读量:7226 次
发布时间:2019-06-29

本文共 2567 字,大约阅读时间需要 8 分钟。

 

前面的文章  中 已经提到Android的开机启动,但是在Android 4.0 有时可以接收到开机启动广播,有时却不可以。经过分析发现,如果应用程序安装上始终没有被打开过,那么在Android启动时,该应用无法接收到开机启动 广播android.permission.RECEIVE_BOOT_COMPLETED。

原来在Android 3.1的更新文档中已经做了说明。

下面是引自Android官方API说明,地址 

原文如下

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.

  •  — Include intent filters of stopped applications in the list of potential targets to resolve against.
  •  — 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  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 the 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的广播添加了FL​​AG_EXCLUDE_STOPPED_PACKAGES标志。它这样做是为了防止广播无意中的或 不必要地开启组件的stoppped应用程序的后台服务。后台服务或应用程序可以通过向广播Intent添加 FLAG_INCLUDE_STOPPED_PACKAGES标志来唤醒处于停止状态(stopped state)的应用程序。

应用程序处于停止状态情况有两种,一种是他们是第一次安装,但尚未启动,另一种是在管理应用程序中由用户手动停止。

 

简单的说,就是防止开机启动恶意程序,优化启动。经过验证发现,系统级的应用程序是可以接收到开机启动广播的。

 

转自 http://blog.csdn.net/leilu2008/article/details/8933869

转载于:https://www.cnblogs.com/CaptainLin/p/3619533.html

你可能感兴趣的文章
RIP路由配置实例V2
查看>>
Bytescout Spreadsheet SDK for.NET
查看>>
我的友情链接
查看>>
Haproxy的三种保持客户端会话保持方式
查看>>
iOS的数学函数
查看>>
python 模块 chardet下载及介绍(转)
查看>>
能力工场--关于在JavaScript中使用EL表达式的问题
查看>>
NFS服务器设置
查看>>
s:iterator 中的status 使用方法
查看>>
cocos2d-x 源码剖析系列
查看>>
IT系统架构设计
查看>>
Nginx虚拟主机配置实践(一)
查看>>
细谈Spring(一)spring简介
查看>>
网络工程师的面试题
查看>>
nginx启动脚本
查看>>
常用输入法框架简介
查看>>
记录新机房建设。20130629
查看>>
安装ntop
查看>>
ssh远程登录讲解
查看>>
mysql的备份脚本
查看>>