2013-07-22 35 views
0

我有一個action_send意圖,允許用戶發送電子郵件,但是當他們完成後,我想將它們返回到與發送電子郵件時不同的活動。 我的意圖代碼如下:android action_send intent如何知道一封電子郵件已發送關閉當前活動?

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(); 
    } 

} 

回答

0

如果你想返回到某些活動的過程中收到了送你必須做出與標誌的意圖,清除活動的頂部的電子郵件。您可以使用Intent.FLAG_ACTIVITY_CLEAR_TOP

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
相關問題