is there something like MFMailComposeViewController in iPhone for Android, basicly Activity which handles email addresses and email creation etc. ? or all must be made from scratch by me?开发者_JAVA技巧
cheers, /Marcin
I dont know about the MFMailComposeViewController
from iPhone but I don know Intents of Android. You can use these to send input gathered from user and allow device installed email clients to handle it for you.
try{
Intent emailIntent=new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"sample@email.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Sample Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Sample Body");
emailIntent.setType("text/plain");
startActivity(emailIntent);
}catch(android.content.ActivityNotFoundException ex){
//Theres no email client installed on users device.
}
You can use EditText android widgets to accept input from user. Use EditText.getText()
to
do so.
You can also specify that you want to use default email client of the device by setting up intent with
emailIntent.setClassName(com.android.email, com.android.email.activity.MessageCompose);
This will launch default email clients compose window. Where use may choose to edit and send message.
Make sure you always catch ActivityNotFound exception since there might not be any available email clients installed and/or configured.
精彩评论