Reputation: 11
trying to use Email intent on emulator logged in to Gmail on emulator but still, it is not connecting to Gmail.
Intent email = new Intent(Intent.ACTION_SENDTO);
email.setData(Uri.parse("mailto:")); // only email apps should handle this
email.putExtra(Intent.EXTRA_SUBJECT, "Your Order");
email.putExtra(Intent.EXTRA_TEXT,pricemessage);
if (email.resolveActivity(getPackageManager()) != null)
{
startActivity(Intent.createChooser(email, "Send Mail Using :"));
}
Upvotes: 0
Views: 578
Reputation: 615
When I copied your code, it warned that Query Permission Needed. So, add the below code outside of tag in your manifest.xml file.
<queries>
<intent>
<action android:name="android.intent.action.SENDTO" /><data android:scheme="*" />
</intent>
</queries>
It works for me after adding it. Let me know if it works for you too.
Upvotes: 0
Reputation: 2023
You can easily send email in android via intent. You need to write few lines of code only as given below
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
//need this to prompts email client only
email.setType("message/cfr893");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
Upvotes: 1