2012-02-01 15 views
75

を使用してアプリケーションから電子メールを送信しようとしましたが、電子メールのToフィールドにデータが入力されません。件名やテキストを記入するコードを追加しても問題ありません。 Toフィールドだけが入力されません。Intent.EXTRA_EMAILがToフィールドにデータを入力していません

"text/plain"と "text/html"にタイプを変更しようとしましたが、同じ問題が発生します。誰でも助けてくれますか?

public void Email(){ 

    Intent emailIntent = new Intent(Intent.ACTION_SEND); 
    emailIntent.setType("message/rfc822"); //set the email recipient 
    String recipient = getString(R.string.IntegralEmailAddress); 
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL , recipient); 
    //let the user choose what email client to use 
    startActivity(Intent.createChooser(emailIntent, "Send mail using...")); } 

は、私が使用しようとしている電子メールクライアントは、私はあなたはそれがあるべきarray of string

としてrecipientを渡していないと思うのGmail

答えて

186

ある

emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "[email protected]" }); 
+9

Android ...なぜあなたはとても哀れですか? –

+2

haha​​ha、あなたは+1百万の@BugsHappen ..笑いました。理由:オープンソースですがドキュメントは100%満足ではなく、デバイスメーカーはニーズに応じて変更します(ほとんどのデバイスは安価で無駄です)。 .android.com " – MKJParekh

+4

また、list.toArray()はString [] *ではなくObject []を生成するので、 'intent.putExtra(Intent.EXTRA_EMAIL、list.toArray())' **を実行していないことを確認してください。 * – kape123

1
private void callSendMeMail() { 
    Intent Email = new Intent(Intent.ACTION_SEND); 
    Email.setType("text/email"); 
    Email.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" }); 
    Email.putExtra(Intent.EXTRA_SUBJECT, "Feedback"); 
    startActivity(Intent.createChooser(Email, "Send mail to Developer:")); 
} 
4

使用のようなこの

public void Email(){ 
    // use this to declare your 'recipient' string and get your email recipient from your string xml file 
    Resources res = getResources(); 
    String recipient = getString(R.string.IntegralEmailAddress); 
    Intent emailIntent = new Intent(Intent.ACTION_SEND); 
    emailIntent.setType("message/rfc822"); //set the email recipient 
    emailIntent.putExtra(Intent.EXTRA_EMAIL, recipient); 
    //let the user choose what email client to use 
    startActivity(Intent.createChooser(emailIntent, "Send mail using...")); 

``} 

これはこれは、Androidドキュメントは受信者の電子メールアドレス「を」すべてのIntent.Extra_Email
-Aの文字列配列について言うことです:)
に動作します。データスキーム:
だから、あなたは続きを読むhttp://developer.android.com/guide/topics/resources/string-resource.html http://developer.android.com/guide/components/intents-common.html#Email
こっちとここかACTION_SENDTOアクションを使用して「MAILTO」を含めることができる文字列を適切 を養う必要があります。例:

Intent intent = new Intent(Intent.ACTION_SENDTO); 
intent.setData(Uri.parse("mailto:")); // only email apps should handle this 
intent.putExtra(Intent.EXTRA_EMAIL, addresses); 
intent.putExtra(Intent.EXTRA_SUBJECT, subject); 
if (intent.resolveActivity(getPackageManager()) != null) { 
    startActivity(intent); 
} 
関連する問題