`
iaiai
  • 浏览: 2211265 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Android 4.0 消息广播无法接收的原因

 
阅读更多
直接上一篇老外的文章:大意是:android 4.0为了防止一些malware(恶意软件)不经用户启动就在后台运行,默认安装的程序在用户启动前是完全被系统忽略的,即使程序注册了广播,系统也不会给该程序传递广播。只有程序被用户运行过之后,消息广播才会生效。而且,即使程序已经运行过了,如果被用户Force Stop(强制停止),又会回到被系统忽略的状态。这个问题其实从3.1的时候就已经有了,最近用4.0的系统测试才发现了这个问题的存在,引起不少麻烦。

Broadcast Regression Confirmed
In a previous post, I cited evidence that the BOOT_COMPLETED broadcast will not work out of the box on Android 3.1 until the user uses your app.
It’s actually somewhat bigger than that.
In the issue that I filed seeking clarification, Ms. Hackborn indicated:
Starting with 3.1 when applications are installed they are in a “stopped” state so they will not be able to run until the user explicitly launches them. Pressing Force Stop will return them to this state.
As a result, when applications are first installed, they are totally ignored by the system until and unless the user manually launches something: clicking on a launcher activity or adding an app widget, most likely.
Developers who had been relying upon getting some sort of system broadcast without user intervention will need to adjust their apps for Android 3.1.
As I wrote in the previous post:
I expect that most apps will be OK. For example, if your boot receiver is there to establish an AlarmManager schedule, you also needed to establish that schedule when the app is first run, so the user does not have to reboot their phone just to set up your alarms. That pattern doesnot change – it’s just that if the user happens to reboot the phone, it will not set up your alarms, until the user runs one of your activities.
UPDATE: To clarify the above quote, once the user runs the app for the first time (and does not Force Stop it), everything behaves as before — a reboot will cause BOOT_COMPLETED broadcasts to be received and so on. However, if the user installs the app, until and unless they run the app manually, no broadcasts will be received. And if the user force-stops the app, until and unless they run the app manually, no broadcasts will be received.
This change is not terribly shocking, as it ratchets up the security another notch by limiting ways malware can run without user knowledge. While it does not offer perfect security — the malware can still install its own copy of an Angry Birds launcher icon and hope users screw up — it is an improvement.
分享到:
评论

相关推荐

    android 4.0接收开机广播

    标题“android 4.0接收开机广播”涉及到的就是如何在Android 4.0版本上创建一个能监听并响应设备开机完成的广播接收器。开机广播在Android中是一个非常重要的系统广播,当设备启动完成后,系统会发出ACTION_BOOT_...

    Android 4.0 网络编程详解 王家林.pdf

    在讨论Android 4.0网络编程的知识点之前,需要了解Android 4.0(代号Ice Cream Sandwich,简称ICS)是Google在2011年发布的Android操作系统版本。它集成了之前的版本特色,并且首次尝试统一了平板和手机平台的用户...

    蓝牙BLE4.0接收广播App

    蓝牙BLE4.0接收广播App,手机模拟BLE设备的话可以通过我的另一个下载——手机模拟BLE设备发送广播App. 这两个App可以完成2台Android手机,通过BLE4.0进行通信,可以发送和接收数据。 其中一台Android手机T模拟发出...

    Android 4.0 MusicPlayer 源码

    源码分析可以帮助我们深入理解Android多媒体处理、服务、广播接收器以及UI设计等方面的知识。 首先,让我们来探讨Android多媒体处理。在Android 4.0 MusicPlayer的源码中,主要使用了`MediaPlayer`类来播放音频文件...

    android4.0源码

    7. **BroadcastReceiver**:广播接收器的源码分析有助于开发者理解系统广播事件的工作原理,以及如何注册和编写自定义广播接收器。 8. **权限管理系统**:Android 4.0的权限管理在源码中清晰可见,可以帮助开发者更...

    android4.0 Setting设置 源代码

    5. **BroadcastReceiver**:为了监听系统状态变化,Setting应用会注册BroadcastReceiver,如当Wi-Fi状态改变时,Setting应用会接收到相应的广播并更新UI。 6. **IntentService**:对于耗时的操作,如网络请求或数据...

    android 4.0 桌面时钟源码DeskClock

    在这些类中,我们可以看到Android的Intent机制如何用于启动和切换活动,以及BroadcastReceiver如何接收系统广播,例如电源状态变化或闹钟触发。 DeskClock的闹钟功能是其重要组成部分。在AlarmManager的帮助下,...

    android 4.0 launcher分析

    一个标准的APK文件包含了四大组件:Activity(应用程序的窗口)、Service(后台运行的服务)、BroadcastReceiver(广播接收器)和ContentProvider(数据共享)。在Launcher中,Activity尤为重要,因为它直接响应用户...

    android4.0 联系人源代码

    9. **Intent与广播接收者**:Android通过Intent进行组件间通信。联系人应用可能通过Intent启动其他组件,如启动电话拨号器。同时,它还可能包含广播接收者来监听系统事件,如新联系人添加或数据同步完成。 10. **...

    android4.0短信源码

    Android 4.0的Mms服务基于Android的消息框架,由多个组件共同协作完成。主要涉及以下几个关键部分: 1. **PduProvider**:这是一个Content Provider,负责存储MMS消息的数据,包括短信的协议用户数据单元(PDU)和...

    android4.0源代码

    7. **Broadcast Receiver**:广播接收者是Android事件驱动模型的重要部分,源代码揭示了其工作原理和注册机制。 8. **Intent和Intent Filter**:源代码中的Intent和Intent Filter实现,展示了Android如何通过意图...

    android 4.0 屏蔽 Home键

    针对Android 4.0(Ice Cream Sandwich)系统,由于其对用户体验和系统架构的一系列改进,传统在Android 2.x上屏蔽Home键的方法不再适用。本篇将详细介绍如何在Android 4.0中实现Home键的屏蔽。 首先,我们回顾一下...

    ICS android4.0源代码

    通过分析这些源代码,开发者可以学习到Android系统如何管理活动(Activity)、服务(Service)、广播接收器(Broadcast Receiver)以及内容提供者(Content Provider),理解系统级的事件处理机制,如触摸事件和...

    android4.0 VoiceDialer源码

    7. **广播接收器的应用** BroadcastReceiver在VoiceDialer中用于监听系统广播,例如电话状态的改变,当用户在通话中时,VoiceDialer可以暂停语音识别,防止误操作。这体现了Android的事件驱动编程模式。 通过对...

    张泽华android4.0视频 Android配合测试代码

    在Android 4.0(API级别14)的开发环境中,理解和掌握文件访问权限、服务和服务生命周期以及广播接收器的使用是至关重要的。张泽华的这个视频教程通过具体的代码示例,详细讲解了这些关键知识点,旨在帮助开发者更...

    张泽华android4.0源代码

    《张泽华Android 4.0源代码解析》 Android 4.0,又被称为Ice Cream Sandwich(冰淇淋三明治),是Google推出的一个重要的Android版本,它为移动设备带来了一系列新特性和改进。本课程配套代码由知名讲师张泽华提供...

    Android 4.0开发教程 Apress

    根据提供的文件信息,以下是关于《Android 4.0开发教程 Apress》一书的知识点梳理: 1. Android计算平台介绍 Android 4.0开发教程开始于对Android计算平台的介绍,强调了移动设备如何转变成计算平台,使得无论是...

    android4.0蓝牙串口源码

    8. **源码分析**:实际源码中可能包含了服务(`Service`)来管理蓝牙连接,以及广播接收器(`BroadcastReceiver`)来监听蓝牙状态变化。还可能有专门的线程来处理读写操作,以避免阻塞UI主线程。 9. **设备发现与...

    Android蓝牙4.0例子

    在这个"Android蓝牙4.0例子"中,我们将深入探讨如何实现搜索蓝牙设备、建立连接以及进行数据的发送与接收。 首先,Android蓝牙4.0的核心API位于`android.bluetooth`包下,主要类包括`BluetoothAdapter`,`...

    Android 4.0 源码

    Android 4.0,也被称为Ice Cream Sandwich (ICS),是Google...源码的探索不仅限于上述内容,还包括了各种服务、广播接收器、内容提供者以及其他组件的实现,对于有志于Android底层开发的人来说,这是一个宝贵的资源。

Global site tag (gtag.js) - Google Analytics