문제가 있습니다. 가끔 IntentService UpdateService02
이 실행되지 않습니다. 37 : 나는 ...IntentService가 특정 상황에서 실행되지 않습니다.
02-28 21 내가 디버깅 할 수 있도록에서 로그 항목을 넣고 여기에 내가 무엇을 얻을 32.461가 : - : 37 : 32.484 : 홈페이지 브로드 캐스트
02-28 (21)를 보낸 브로드 캐스트 리시버를 - 시작된 메인; 알람 설정
02-28 21 : 37 : 32.539 : 브로드 캐스트 리시버 - AlarmService
02-28 21 수신 : 38 : 32.500을 : 브로드 캐스트 리시버 - AlarmService
수신은
보통 이런 일이 발생한다 :
02-28 21 : 37 : 32.461이 : - : 37 : 32.484 : 홈페이지 브로드 캐스트
02-28 (21)를 보낸 브로드 캐스트 리시버 - 주요 시작; 알람 설정
02-28 21 : 37 : 32.539 : 브로드 캐스트 리시버 -
02-28 21 AlarmService
수신 : 38 : 32.500 : UpdateService - onHandleIntent()
어떤 아이디어?
public class AlarmReceiver extends BroadcastReceiver {
private static final int INTERVAL = 60*1000; // check every 60 seconds
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction() != null) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.v(TAG, "BroadcastReceiver - Received Boot Completed; Set Alarm");
setRecurringAlarm(context);
}else if(intent.getAction().equalsIgnoreCase(Main.BROADCAST_STARTUP)){
Log.v(TAG, "BroadcastReceiver - Main Started; Set Alarm");
setRecurringAlarm(context);
}else{
Log.v(TAG, "BroadcastReceiver - Received " + intent.getAction());
}
}else{
Log.v(TAG, "BroadcastReceiver - Received AlarmService");
Intent i = new Intent(context, UpdateService02.class);
context.startService(i);
}
}
private void setRecurringAlarm(Context context) {
Intent receiver = new Intent(context, AlarmReceiver.class);
PendingIntent recurringDownload = PendingIntent.getBroadcast(context, 0, receiver, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarms = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarms.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), INTERVAL, recurringDownload);
}
}
의도 서비스 : 여기에 ...
방송 수신기 내 방송 수신기 코드의 나는 그것이 내가 응용 프로그램이기 위하여 intentservice 시작의 컨텍스트를 설정해야 될 줄 알았는데
public class UpdateService02 extends IntentService {
static DefaultHttpClient mClient = Client.getClient();
private static final int LIST_UPDATE_NOTIFICATION = 100;
public UpdateService02() {
super("UpdateService02");
}
@Override
protected void onHandleIntent(Intent intent) {
Log.v(TAG, "UpdateService -- onHandleIntent()");
try {
HttpGet httpget = new HttpGet(url);
HttpResponse response;
response = mClient.execute(httpget);
BufferedReader in = new BufferedReader (new InputStreamReader(response.getEntity().getContent()));
Intent i = new Intent(BROADCAST_UPDATE);
i.putExtra("text", in.readLine().toString() + " updated");
sendBroadcast(i);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
, 그러나 나는 정직하게 모른다.
어디에서 UpdateService - onHandleIntent() 로그를 넣었습니까? onStartCommand() 서비스에서? – user936414
내 IntentService를 보여주기 위해 편집 해 줄 수 있다고 생각했습니다. – Rawr
IntentService가 실행되지 않을 때 서비스가 이미 실행되고 있는지 확인 했습니까? – user936414