Intent.EXTRA_EMAIL non popolando il field To
Sto provando ad usare l' intenzione di submit un'email dalla mia applicazione, ma il field To dell'email non verrà popolato. Se aggiungo il codice per riempire il sobject o il text, funzionano bene. Solo il field A non popolerà.
Ho anche provato a cambiare il tipo a "text / plain" e "text / html" ma ho lo stesso problema. Qualcuno può aiutare per favore?
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...")); }
Il client di posta elettronica che cerco di utilizzare è Gmail
3 Solutions collect form web for “Intent.EXTRA_EMAIL non popolando il field To”
Penso che non passi il recipient
come un arrays of string
dovrebbe essere come
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "someone@gmail.com" });
Usa questo
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...")); ``}
Questo functionrà 🙂
Questa è la documentazione di android che dice su Intent.Extra_Email
-Un insieme di stringhe di tutti gli indirizzi di posta elettronica "A" destinatari.
Quindi devi alimentare correttamente la string Puoi leggere di più qui
http://developer.android.com/guide/components/intents-common.html#Email e qui http://developer.android.com/guide/topics/resources/string-resource.html Oppure utilizzare l'azione ACTION_SENDTO e includere lo schema di dati "mailto:". Per esempio:
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); }
private void callSendMeMail() { Intent Email = new Intent(Intent.ACTION_SEND); Email.setType("text/email"); Email.putExtra(Intent.EXTRA_EMAIL, new String[] { "me@gmail.com" }); Email.putExtra(Intent.EXTRA_SUBJECT, "Feedback"); startActivity(Intent.createChooser(Email, "Send mail to Developer:")); }