我已经在我的 AsyncTask 中与服务器进行了一些通信。现在,根据该数据,我想转到屏幕 A 或屏幕 B。正确的方法是什么?
我应该在 postExcute 部分调用新活动吗?我目前在启动画面上。
private class CheckLoginDetails extends AsyncTask<Void, String, String> {
protected void onPreExecute() {
//does stuff before excuting code
}
//does the main operation
protected String doInBackground(Void... params) {
publishProgress("10", "Checking Login Details Exist . . .");
if(checkForLogin()){
//validate with DB
publishProgress("20", "Logging in, verifying . . .");
if(sendforVerif()){
publishProgress("100", "You Are Logged In!");
}else{
publishProgress("100", "Error Logging In.");
}
}else{
//login or registration required
publishProgress("100", "Login Required . . .");
}
return null;
}
//Update Progress
protected void onProgressUpdate(String... values) {
mProgress.setProgress(Integer.parseInt(values[0]));
statusReadout.setText(values[1]);
}
//Update UI with results
protected void onPostExecute() {
Intent intent = new Intent(SplashScreen.this, MenuScreen.class);
SplashScreen.this.startActivity(intent);
}
}
我不认为这是正确的,而且它不起作用!?
TIA