2013-04-04 48 views
0

我在android中製作一個應用程序,我試圖做到這一點,當你點擊一個按鈕時,它會打開一個你選擇的電子郵件應用程序(即時通訊使用Gmail)和自動組成一個電子郵件,我怎麼讓這個發送地址已填入>創建電子郵件,發送地址已經填寫在android

這是我的代碼

public void send(View v){ 
    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
    emailIntent.setType("text/plain"); 
    startActivity(emailIntent); 
    } 
+0

你爲什麼用你甚至不使用參數傳遞...? – JoxTraex 2013-04-05 00:12:26

回答

0

這是你所需要的。

emailIntent.putExtra(Intent.EXTRA_EMAIL, "your_email_address"); 
0

@ user2109242

我會建議你使用下面的代碼,因爲它會幫助你選擇源像之一:電子郵件時,Gmail和Skype以及電子郵件的狀態,如:送出沒

public void sendFeedbackMessage(String subject, String message) { 

     Intent i = new Intent(Intent.ACTION_SEND); 
     i.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"}); 
     i.putExtra(Intent.EXTRA_SUBJECT, subject); 
     i.setType("message/rfc822"); 
     i.putExtra(Intent.EXTRA_TEXT, message); 
     try { 
      startActivity(Intent.createChooser(i, "Send email via :")); 
      Toast.makeText(ReservationActivity.this, "Email Sent.", Toast.LENGTH_SHORT).show(); 
     } catch (android.content.ActivityNotFoundException ex) { 
      Toast.makeText(ReservationActivity.this, "There are no email applications installed.", Toast.LENGTH_SHORT).show(); 
     } 


     } 
相關問題