简体   繁体   English

如何从我的活动中以编程方式启动Android电子邮件设置屏幕

[英]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. 当我已经在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. 如果我还没有设置我的电子邮件帐户,那么下面的代码将带我编写我不想要的SMS / MMS,请提供您的建议。

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. SDK不支持该功能,主要是因为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. CommonsWare是正确的,因为没有默认的电子邮件应用程序,所以Android中没有电子邮件设置屏幕。 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". 为此,请将意图类型设置为“ message / rfc822”。 This will call only the apps which can handle that MIME, in short, the e-mail apps. 简而言之,这将仅调用可以处理该MIME的应用程序,即电子邮件应用程序。

Put startActivity in try, catch ActivityNotFoundException. 尝试放入startActivity,捕获ActivityNotFoundException。 When this exception is caught, you can inform the user to setup an e-mail account. 捕获到此异常后,您可以通知用户设置一个电子邮件帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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