【发布时间】:2010-11-15 13:50:21
【问题描述】:
我的异步任务中有这段代码:
@Override
protected void onPreExecute() {
waitDialog = new ProgressDialog(context);
waitDialog.setTitle(R.string.wait_title);
waitDialog.setMessage(context.getString(R.string.wait_body));
waitDialog.setIndeterminate(true);
waitDialog.show();
}
@Override
protected Boolean doInBackground(Void... unused) {
Intent serviceIntent = new Intent(context, PublisherService.class);
saveSettings(false);
startService(serviceIntent);
return serviceIsRunning();
}
对话框显示,但是当我的服务启动时(需要几秒钟),progressdialog 被冻结。如果我在我的doInBackground() 调用中使用简单的SystemClock.sleep(),它就可以正常工作。
谁能告诉我为什么会这样以及如何解决这个问题?
谢谢
【问题讨论】:
标签: android service android-asynctask