BOOT_COMPLETED not called on Honeycomb after expor

2019-02-10 22:58发布

问题:

I have a very weird problem, and none of the questions already on the website have an answer or the same problem.

I have an app that receives BOOT_COMPLETED. I made sure it could receive the intent by setting android:installLocation to internalOnly. I have a Log.Debug in my OnBoot class, confirming wether or not it was called.

I have two devices, an Android 2.2, and a Honeycomb. On android 2.2, it works fine, but Honeycomb...

  • If I install the application on the honeycomb tablet with eclipse's "run" button, onBoot is called when the tablet boots.

  • If I install the application on the honeycomb tablet after exporting the *.apk file, onBoot is never called.

  • If I install the application on the honeycomb tablet after exporting the *.apk file, AND manually start an activity before rebooting, onBoot is called.

It seems like the application needs its activity to be started at least once for the receiver to be registered... It doesn't feel right, since an app might have no activity, and the Froyo doesn't work that way...

回答1:

This works as intended, assuming you are using android 3.1. and later.

Applications installed on 3.1 and later are in the stopped state after installation. They have to be explicitly started by the user at least once to get out of that.

Applications in stopped state don't receive any broadcast intents, including BOOT_COMPLETED.

See Android 3.1. - API Overview - Launch controls on stopped applications