Get Email Address From Intent Filter In Android
How can I get email that comes through intent-filter in android ? Currently I tried this, I could get the Action SEND, but the Extra_EMail is null. Intent intent = getIntent();
Solution 1:
it should work only if you are passing recipient as array of string
try like this:
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
newString[] { "someone@gmail.com" });
Solution 2:
Here is my helper function to send emails:
publicstaticIntentemail(Context context, String[] addresses, String subject, String body, Uri attachment) {
Intent intent = newIntent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
if (addresses != null)
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
if (body != null)
intent.putExtra(Intent.EXTRA_TEXT, body);
if (subject != null)
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
if (attachment != null)
intent.putExtra(Intent.EXTRA_STREAM, attachment);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}
You can use it this way inside an Activity:
startActivity(email(this, newString [] {"abc@def.com", "Subject of email", "Message inside email", null));
Post a Comment for "Get Email Address From Intent Filter In Android"