简体   繁体   中英

auto start app when boot completed android

I've been reading a lot on this subject but for some reason I'm unable to make this work. My application records the location of the user every 5 minutes. When the user reboots the phone I'm unable to auto start the app. I'm able to check the location of the user every 5 minutes so the alarms are working.

Here is my android manifest file

<receiver android:name=".AlarmBroadcastReceiver" ></receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

and the AlarmBroadcastReceiver public class AlarmBroadcastReceiver extends BroadcastReceiver{

public void onReceive(Context context, Intent intent) {
    Log.d("LOG","I've been Called");}

What I'm doing wrong?

Add:

<intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>

To your <receiver> element in the manifest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM