0

ユーザーがメールを送信できるようにするaction_sendインテントがありますが、完了したら、メールが送信されたときとは異なるアクティビティに戻りたいと思います。私のインテントコードは以下の通りです:

public void sendEmail(){
    String path = Environment.getExternalStorageDirectory().toString() + "/" + "screenshots/";
    String target_filename = "CheeseNav.jpg";
    File externalFile = new File(path, target_filename);

            Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
    i.putExtra(Intent.EXTRA_SUBJECT, "Email sent from android app");
    i.putExtra(Intent.EXTRA_TEXT, "");
    Uri sendUri = Uri.fromFile(externalFile);
    i.putExtra(Intent.EXTRA_STREAM, sendUri);

    try{
        startActivity(Intent.createChooser(i,  "Send mail..."));
    } catch(android.content.ActivityNotFoundException ex){
        Toast.makeText(ScreenViewer.this, "There are no email clients installed.",
                Toast.LENGTH_SHORT).show();
    }

}
4

1 に答える 1

0

電子メールを送信するプロセスの前にあったアクティビティに戻りたい場合は、アクティビティの上部をクリアするためにフラグを使用してインテントを作成する必要があります。Intent.FLAG_ACTIVITY_CLEAR_TOP を使用できます

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
于 2013-07-22T18:02:46.270 に答える