2012-10-29 2 views
1

서비스를 시작하지 못하는 간단한 IntentService 스켈레톤을 만들었습니다. 메인 코드 블록과 매니페스트 항목을 추가했지만 아직 로그 출력을 얻지 못했습니다. 여기 다른 유사한 답변을 확인하지만 한 나는에 항목 추가하는 매니페스트에 모든 점 :InsentService가 호출되지 않았지만 Manifest에 있음

매니페스트 :

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" 
    android:name=".ApplicationGlobal"> 

    <service android:name=".MyIntentServiceImpl" /> 

서비스 시작 :

Intent intent = new Intent(ThisActivity.this, MyIntentServiceImpl.class); 
startService(intent); 

서비스 코드 :

public class MyIntentServiceImpl extends IntentService implements MyIntentService { 

private boolean result; 
private Long pollingCount; 

public MyIntentServiceImpl(){ 
    super("MyIntentServiceImpl "); 
    Log.d(TAG, "Creating Polling Service"); 
    this.result = false; 
    this.pollingCount = 0L; 
} 

@Override 
protected void onHandleIntent(Intent arg0) { 
    Log.d(TAG, "Polling Service Started"); 

    while(!result && (pollingCount <= MAX_POLLING_VALUE)){ 
     pollingCount++; 
     Log.d(TAG, "Polling for Result Request (" + pollingCount.toString() + ")"); 
    } 

    Log.d(TAG, "Polling Service Finished"); 
+0

LogCat을 검사하고'startService()'호출 시점의 메시지를 찾으십시오. – CommonsWare

답변

0

로그 캣을 확인하십시오. Android에서 서비스를 찾을 수 없다고 말하고 있습니까? 즉, 인 텐트가 올바르게 코딩되지 않았 음을 의미합니다.

정말 startService를 부르시겠습니까? 어떤 전화를 건간에 두 줄만 제공 했으므로 매니페스트에 표시하지 않습니다.

내가 디버깅을 시작하는 방법은 startService가 호출되고 있음을 스스로에게 확신시키는 것입니다. 가장 좋은 방법은 Eclipse의 디버거를 사용하여 디버그하는 것인데, 이지만을 주석 처리하고 "startService"를 주석 처리하고 로그 문으로 대체 할 수도 있습니다. 이것이 로그에 나타나지 않으면 startService가 도달하지 않았 음을 알 수 있습니다.

관련 문제