android之4.0开机自接受广播,启动服务的问题

从Android 3.1开始,系统针对开机启动应用进行了控制,特别是针对未被用户手动启动过的程序,以防止恶意程序开机启动。系统级应用除外。文章介绍了启动停止程序的控制机制,并指出默认情况下,广播Intent不会激活已停止的应用,但可以通过特定Flag进行设定。
摘要由CSDN通过智能技术生成
    
    在Android 4.0中如果一个程序如果只是安装了,但是重来都没有运行启动过,那么系统将会忽略这个程序,因此在系统开机时,该程序时将始终无法获取系统开机广播的---------》没有发送怎么会有接受。
    因此Android 4.0及以上如果想接受系统广播至少要先运行程序一次。(其实 Android 3.1就开始了,这么说是为了针对我们开发最多android 4.0);
   


   简单的说,这样是是为了防止开机启动恶意程序,优化启动。(防止病毒等开机启动程序危害系统,所以andoird4.0不允许没有被用户手动启动过的程序进行开机启动);

   经过验证发现,系统级的应用程序是可以接收到开机启动广播的。


     Android 4.0 无法接收开机广播的问题本身是因为,如果应用程序安装上始终没有被打开过,那么在Android启动时,该应用无法接收到开机时的系统广播android.permission.RECEIVE_BOOT_COMPLETED。
    其实在google的android 3.1APIs更新文档中已经做了说明。

  

   下面是引自Android官方3.1APIs说明地址 http://developer.android.com/about/versions/android-3.1.html#launchcontrols 。


原文如下(后面有对应的翻译):

Launch controls on stoppedapplications

Starting from Android 3.1, the system's package manager keeps track ofapplications that are in a stopped state and provides a means of controllingtheir launch from background processes and other applications.

Note that an application's stopped state is not the same as an Activity'sstopped state. The system manages those two stopped states separately.

The platform defines two new intent flags that let a sender specifywhether the Intent should be allowed to activate components in stoppedapplication.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值