这是我的登录代码。
public void Login_Click(View view) {
HashMap<String, String> op_Config = XMLParser
.parse(LoginActivity.this);
}
完成执行大约需要4秒。所以我添加了这样的进度对话框。
public void Login_Click(View view) {
new IsLogedIn().execute();
}
class IsLogedIn extends AsyncTask<String, String, String>
{
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(progress_bar_type);
}
@Override
protected String doInBackground(String... value) {
try
{
HashMap<String,String> op_Config = XMLParser.parse(LoginActivity.this);
finish();
Intent intent=new Intent(LoginActivity.this,MainMenuActivity.class);
startActivity(intent);
}
catch (Exception e) {
}
}
@Override
protected void onPostExecute(String file_url) {
dismissDialog(progress_bar_type);
}
}
但现在完成时间超过1分钟。
答案 0 :(得分:6)
尝试这样做
class IsLogedIn extends AsyncTask<String, String, String>
{
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(progress_bar_type);
}
@Override
protected String doInBackground(String... value) {
try
{
HashMap<String,String> op_Config = XMLParser.parse(LoginActivity.this);
}
catch (Exception e) {
}
}
@Override
protected void onPostExecute(String file_url) {
if(dilog.isShowing()){
dismissDialog(progress_bar_type);
}
finish();
startActivity(new Intent(LoginActivity.this,MainMenuActivity.class));
}
}