1

부팅 할 때 시작되고 백그라운드에서 실행되는 IntentService가 있습니다. 실행 프로그램 활동이 없으며 IntentService가 브로드 캐스트 리시버에 의해 호출됩니다. 2.3.4 및 4.0.4 장치에서는 작동하지만 4.2.2에서는 작동하지 않습니다. 기기에서 내 브로드 캐스트 리시버가 트리거되지 않았을 수 있습니까?Android IntentService가 부팅시 시작되지 않음

매니페스트 :

<?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); 
    } 
} 
+0

수신자가 의도를 얻었습니까? 나는 메나, 당신의 onReceive 방법이 불려지나요? – edoardotognoni

+0

활동이 아니므로 디버깅 할 수 없습니다. 확인하려면 어떻게해야합니까? – Piovezan

+0

startServiceIntent를 만들기 전에 Log.d ("DEBUG", "Creating intent"); 이 문자열이 logcat에 기록되는지 확인하십시오 – edoardotognoni

답변

2

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

을 변경해보십시오

+0

효과가있었습니다! 고마워요! – Piovezan

관련 문제