/**
* From Android 3.1, newly installed apps are always put into a “stopped” state and the only way to move it out of the stopped
* state is to manually launch any Activity of the app at least once.
* 1) You need to design a mechanism where the user needs to first open any Activity of the app manually after installing the app.
* 2) After that, your BootReceiver will work correctly and it will be able to launch any Activity of that app automatically. Your
* implementation is absolutely correct.
* I faced the same problem in one of my apps, where I was trying to open an Activity every time the device boots but it didn’t
* work for a newly installed app. Once the user opens the app manually at least once, the app moves out of “stopped” state and
* everything works normally.
*
* EDIT
* 1) Please ensure that the is a direct child of the tag.
* 2) Please ensure that you specify android:installLocation=”internalOnly” otherwise you will not receive any Boot Complete actions if the app is installed in the SD card.
* 3) As I explained before also.
* enter image description here
* From Android 3.1, all apps are put in the stopped state which is the same as when user Force Closes any app.
* While in this state, the application will not run automatically for any reason, until and unless launched
* manually by the user from the launcher.
* Meaning you will not receive ACTION_PACKAGE_INSTALLED, BOOT_COMPLETED etc. until the user manually launches the app. Google has
* taken this decision to prevent malware apps from auto-launching. The user needs to open that app at least once, for it to perform
* actions automatically after that.
*/
在android 3.1之后,新安装的应用默认是“stop”状态,在这种状态下 ACTION_PACKAGE_INSTALLED, BOOT_COMPLETED 等系统广播都是无法接收的,只有当应用被人手动打开一次之后才能正常的接收这些广播。
下面是一个例子:
https://github.com/VenQi/BroadcastDemo
android开机无法自动启动,安装无法自动启动
最新推荐文章于 2022-09-02 22:04:50 发布