gpt4 book ai didi

Android IntentService 不会在开机时启动

转载 作者:行者123 更新时间:2023-11-29 21:42:42 28 4
gpt4 key购买 nike

我有一个 IntentService,它在启动时启动并在后台保持运行。没有启动器 Activity,IntentService 由广播接收器调用。它适用于 2.3.4 和 4.0.4 设备,但不适用于 4.2.2。也许我的广播接收器没有在设备上触发?

list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.xxx"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<receiver android:name="br.com.xxx.RastreadorBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

<service
android:name="br.com.xxx.ObtainAndPostLocationService"
android:exported="true">
</service>

</application>

</manifest>

RastreadorBroadcastReceiver:

package br.com.xxx;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class RastreadorBroadcastReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
Intent startServiceIntent = new Intent(context, ObtainAndPostLocationService.class);
context.startService(startServiceIntent);
}
}

最佳答案

尝试改变

<receiver android:name="br.com.xxx.RastreadorBroadcastReceiver" >

<receiver android:name=".RastreadorBroadcastReceiver" >

关于Android IntentService 不会在开机时启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16671619/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com