I have an application in which there are two buttons - one for email and one for SMS. Depending on the button pressed, I want to send an e-mail or SMS message with a specific text. I encoded the email button and it works fine. The problem is that the pop-up dialog box allows you to send emails or send messages. I want to highlight them, so that when the user clicks on the email, only the email options are available, and when the user clicks the SMS, there is only the messaging option.
Here is the code I tried.
private void sendEmail(){
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subject of the message");
i.putExtra(Intent.EXTRA_TEXT , "Body of the message");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
}
Basically, for both email and messaging, the only intent is Intent.ACTION_SEND.
?