我正在尝试从我的 Android Activity 发送一封电子邮件,如下所示:
@Override
public void onClick(View view) {
processdialog = new ProgressDialog(LoginScreen.this);
processdialog.setTitle("Test mail sturen...");
processdialog.setMessage("even wachten a.u.b...");
processdialog.setCancelable(false);
processdialog.show();
testMailButton.setEnabled(false);
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... arg0) {
try {
properties.setProperty("emailTo", emailContactField.getText().toString());
properties.setProperty("emailFrom", emailField.getText().toString());
properties.setProperty("passWFrom", passwordField.getText().toString());
String[] temp = { properties.getProperty("emailTo").toString()};
setupMail.updateUserInfo(temp,properties.getProperty("emailFrom"), properties.getProperty("passWFrom"));
loggedIn = setupMail.sendTestMail();
loginTryDone = true;
} catch (Exception e1) {
e1.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (processdialog != null) {
processdialog.dismiss();
testMailButton.setEnabled(true);
}
}
};
if(!loggedIn){
task.execute();
但是我的用户界面没有给我进度对话框,只是卡住了几秒钟,直到发送邮件。谁能告诉我我在这里做错了什么?谢谢