我有这个调用 Web 服务并解析 xml 的异步任务
@Override
protected void onPreExecute(){
super.onPreExecute();
time = System.currentTimeMillis();
}
protected Boolean doInBackground(Integer... params) {
//code
}
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
difftime = System.currentTimeMillis() - time;
}
在执行异步任务时,我想显示一个加载屏幕,但是如果我这样做,加载屏幕会在异步任务完成之前完成
super.onCreate(savedInstanceState);
setContentView(R.layout.loading_screen);
final CallWebService callTarif = new CallWebService(6,sett.getDeviceId());
callTarif.execute();
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
LoadingScreen.this.finish();
Intent intent = new Intent(LoadingScreen.this, NextActivity.class);
startActivity(intent);
}
}
},callTarif.difftime);