您的位置:首页 > 移动开发 > Android开发

android 3.1以上boot complete receiver接受的问题

2013-03-08 10:12 337 查看
可以参考如下的解释:

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.

原文详见:

http://stackoverflow.com/questions/9682846/start-service-at-boot-time-for-android-4-0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: