简体   繁体   English

开机完成时自动启动应用程序的android

[英]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. 我的应用程序每5分钟记录一次用户的位置。 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. 我能够每5分钟检查一次用户的位置,以便警报正常运行。

Here is my android manifest file 这是我的Android清单文件

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

and the AlarmBroadcastReceiver public class AlarmBroadcastReceiver extends BroadcastReceiver{ 而AlarmBroadcastReceiver公共类AlarmBroadcastReceiver扩展了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. 到清单中的<receiver>元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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