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..."));

      

+2


a source to share


2 answers


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.

0


a source


is there a way to start the email setup screen from my activity



This is not supported in the SDK, mainly because there is no "email setup screen" in Android. Different email applications may have settings, but different devices will have different email applications installed.

0


a source







All Articles