2017-03-06 110 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可以做,因此它正在破坏自己。

相关问题