I've set up an email intent and tried launching it. Code below:
public void emailSummary(String emailText, String name) {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.putExtra(Intent.EXTRA_EMAIL, "");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "JustJava order for " + name);
emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);
Log.v("MainActivity", "Finished setting up intent");
if (emailIntent.resolveActivity(getPackageManager()) != null) {
startActivity(emailIntent);
Log.v("MainActivity", "Sharing the order summary to email");
} else {
Log.d("MainActivity", "No email app installed!");
Toast.makeText(MainActivity.this, "Uh...No email app?", Toast.LENGTH_SHORT).show();
}
However, when I do press the Order button, the "Uh... No email app?" toast shows up. I have both Inbox and Gmail installed, but the Intent
does not seem to find any of them. Why?