[英]Android IntentService onDestroy being called instead of onHandleIntent
Checked the log for it.. onDestroy() method gets called instead of onHandleIntent() i am using two intent services, and have written similar code for both... but one runs all the time but for the second intentService(code attached)...sometimes it runs and sometimes it doesn't without changing anything in the whole project. 检查了它的日志。onDestroy()方法被调用,而不是onHandleIntent()被调用我正在使用两个Intent服务,并且为这两个都编写了类似的代码...但是一个一直运行,但第二个IntentService一直运行...有时它会运行,有时它会在整个项目中进行任何更改。 can anyone please help?
谁能帮忙吗?
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);
}
}
the task.execute() method in code had a if loop in it and the condition was false. 代码中的task.execute()方法中包含一个if循环,并且条件为false。 so there wasn't anything for the IntentService to do..therefore it was destroying itself.
因此,IntentService没什么可做的。因此它正在破坏自身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.