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 回答