I know there has been hundreds of this kind of question asked, but I've been checking them all for a while and still couldn't find any solution.
I've seen this answer to "Android BOOT_COMPLETED not received when application is closed" said BOOT_COMPLETED
not send to application unless user launch your application first, after Android version 3.1,
but I still see some applications are doing that, so there must be a way. I really need to handle it, otherwise I'm also against to do something without user's interaction.
Here's my AndroidManifest:
<manifest ... >
<!-- to be activated service on boot is completed -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application ... >
<!-- to receive data when boot completed -->
<receiver
android:name="myPackage.BootReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
Edit: There is no much thing to see in my broadcastreceiver but to whom required here it is:
package myPackage
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Utils.LogI("BootReceiver", "BootReceiver received!");
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
// Do my stuff
}
}
}