`
iaiai
  • 浏览: 2141837 次
  • 性别: 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.
分享到:
评论

相关推荐

    蓝牙BLE4.0接收广播App

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

    android 4.0接收开机广播

    首先确定你的手机是否root过,安装成功后打开一次, 重启手机会打开你指定的app, (求大神指教menu屏蔽长按事件)

    手机模拟BLE设备发送广播App

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

    Android 开机广播的使用及配置

    相关文章 Android 4.0 无法接收开机广播的问题 在配置文件AndroidManifest.xml中向系统注册receiver,子节点 intent-filter 表示接收android.intent.action.BOOT_COMPLETED消息 代码如下: <receiver android:name=”...

    ROOT授权管理 Kinguser_v3.4.8

    2、使用全新系统广播技术,发送接收ROOT请求指令,较传统ROOT授权软件有效省电高达90% 3、完美支持市面上所有android(安卓)2.1~ android(安卓)4.0手机,兼容性极高 4、全中文界面,更适合国人使用 5、优秀的UI...

    ranco内核更新器

    本软件需要的权限包括:打开网络接口、访问网络上的信息、接收广播信息、写用户的外部存储器。 本软件支持的系统包括:Android 4.0 本软件支持的屏幕尺寸包括:320- 480、480- 854、480- 800、240- 320、1024- 768、...

    Greenify 绿色守护 2.5.2 beta 2

    软件名称:Greenify绿色守护 ...最新版本:2.5.2 beta 2 ...* 广播接收器。它们响应设备所发生的全局性事件,例如网络连接状态变化、电源改变、短信监听等。 * 定时器。它们在特定的时间或以一定的时间间隔运行。

    30米蓝牙翻页笔设计,翻页随心所欲,附硬件/源码/设计说明等-电路方案

    RF 低功耗模式时接收电流3.3mA (TYP.) RF Power Down 模式时电流0.1uA (TYP.) 无线类型: 蓝牙 蓝牙要求: 兼容蓝牙4.0 及以上的低功耗规格 控制距离: 30 米 适用硬件: 笔记本电脑,台式电脑,安卓手机以及平板 ...

    JAVA上百实例源码以及开源项目

     在对象创建的过程中将被容器调用,onMessage函数方法接收消息参数,将其强制转型为合适的消息类型,同时打印出消息的内容。同时一个mail note将被发送给消息发送者,发送一个e-mail通知给由recipient参数确定的e-...

    JAVA上百实例源码以及开源项目源代码

    消息驱动Bean必须实现两个接口MessageDrivenBean和MessageListener 在对象创建的过程中将被容器调用,onMessage函数方法接收消息参数,将其强制转型为合适的消息类型,同时打印出消息的内容。同时一个mail note将被...

Global site tag (gtag.js) - Google Analytics