2017-03-06 123 views
0

檢查日誌中的on .. onDestroy()方法被調用而不是onHandleIntent() 我使用了兩個intent服務,並且都寫了類似的代碼...但是一次運行所有的時間,但第二個intentService(代碼附加)...有時它運行,有時它不會改變整個項目中的任何東西。 任何人都可以請幫忙嗎?Android IntentService onDestroy被調用而不是onHandleIntent

public class GetDataService extends IntentService { 
    private static final String TAG="GetDataService"; 

    public GetDataService(){ 
     super("GetDataService"); 
    } 
    @Override 
    protected void onHandleIntent(Intent intent) { 
     GetDataTask task= new GetDataTask(); 
     Log.d(TAG,intent.getStringExtra(GetDataTask.INSTA_TOKEN_URL)); 
     task.execute(this,intent); 
     ApplicaitonsData.GetDataServiceRunning=true; 
     Log.d(TAG,"data service running status = "+ ApplicaitonsData.GetDataServiceRunning); 
    } 

    @Override 
    public void onDestroy() { 
     super.onDestroy(); 
     ApplicaitonsData.GetDataServiceRunning=false; 
     Log.d(TAG,"data service running status = "+ApplicaitonsData.GetDataServiceRunning); 
    } 
} 

回答

0

代碼中的task.execute()方法有一個if循環,條件爲false。所以沒有什麼IntentService可以做,因此它正在破壞自己。

相關問題