1
私は既に他の質問を見てきましたが、私は何か違った単純なものがほしいと思います。プログラムでキャッシュをクリアしますか?
私はクリックするとメールアドレスに、java mail apiを使用してウェルカムメールを送信したという活動があります。より具体的には、最初に実行するときにあなたのパスワードとウェルカム電子メールが送信されるアドレスであなたのGmailアカウントを入力してください。今私は間違ったパスワードを入れて例外が作成され、あなたはあなたの実際のパスまたはユーザー名を入力するように求めている。しかし、もし私が本当のことを言えば、それを私にもう一度お願いします。さらに、私が本当のものを入れて、それを缶詰めすれば、それは歓迎メールを送り続けます。どうすればこの問題を解決できますか?ここではサンプルコードは次のとおりです。
EmailValidator val = new EmailValidator();
Boolean a = val.validate(yemail);
Boolean b = val.validate(temail);
if (a == false || b == false){
AlertDialog.Builder box = new AlertDialog.Builder(this);
// Set the message to display
box.setMessage("Please enter a valid email address!");
// Add a neutral button to the alert box and assign a click listener
box.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
// Click listener on the neutral button of alert box
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), "OK", Toast.LENGTH_LONG).show();
}
});
box.show();
}// end if validating emails
if (a == true && b == true && ypass != null){
try { // send mail
GmailSender sender = new GmailSender(yemail,ypass); // SUBSTITUTE HERE
sender.sendMail(
"EMERGENCY", //subject.getText().toString(),
"hi", //body.getText().toString(),
"[email protected]", //from.getText().toString(),
temail //to.getText().toString() address where the mail is sent to
);
}
catch (Exception e) {
AlertDialog.Builder box = new AlertDialog.Builder(this);
// Set the message to display
box.setMessage("Please Re-enter your Gmail username and pasword");
// Add a neutral button to the alert box and assign a click listener
box.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
// Click listener on the neutral button of alert box
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), "OK", Toast.LENGTH_LONG).show();
}
});
box.show();
} // end catching Exception
} // try to send mail
}
...あなたにこの意志は便利願っていますこれを尋ねないでください。無効なGmailアカウントが与えられた場合、認証例外がスローされます。それから私の本当のGmailアカウントを使用して、同じメッセージが私の画面の前に置かれます。したがって、2回目の認証は決して行われません。これは私が訂正したいことです! – dothedos
それから無効な電子メールアドレスが与えられた場合、catcheをクリアする必要があると思います。 – Umesh
さて、私たちはすぐ近くに近づいています。この方法をプログラマティックに行うには?私はユーザーに干渉させたくありません!クリックでそれを言うことができます!サンプルコードを提供できますか? – dothedos