简体   繁体   中英

How to launch android email setup screen programmatically from my activity

I could send mail from my Activity when i have already configured with any email account in android.

But in case if have not configured, is there any way to launch email setup screen from my Activity ,or at least check whether email account is setup before sending a email.

If i haven't set up my email account then the following code takes me to compose 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..."));

is there any way to launch email setup screen from my Activity

That is not supported in the SDK, mostly becuase there is no "email setup screen" in Android. Various email applications may have setup screens, however different devices will have different email applications installed.

CommonsWare is right, there is no e-mail setup screen in Android as there is no default e-mail app. So you need to tell the user to setup an e-mail account before attempting to send e-mail.

To do this, set the intent type to "message/rfc822". This will call only the apps which can handle that MIME, in short, the e-mail apps.

Put startActivity in try, catch ActivityNotFoundException. When this exception is caught, you can inform the user to setup an e-mail account.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM