How to programmatically launch Android email setup screen from my activity
I could send mail from my Activity when I have already configured any email account in android.
But if you haven't configured, is there a way to launch the email setup screen from my activity, or at least check if the email account is configured before sending email.
If I haven't set up my email account then the following code will force me to compose an SMS / MMS, which I don't want. Please give your suggestion.
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, "example.com");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "...");
emailIntent.putExtra(Intent.EXTRA_TEXT,"...");
emailIntent.setType("text/plain");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
a source to share
CommonsWare is right, there is no email setup screen on Android as there is no default email app. Therefore, you need to tell the user to set up an email account before sending the email.
To do this, set the intent type to "message / rfc822". This will only invoke applications that can handle this MIME, in short, email applications.
Put startActivity in try, catch ActivityNotFoundException. When this exception is caught, you can inform the user to set up an email account.
a source to share