Android-打开电子邮件应用程序? [英] Android - Opening the email application?

查看:109
本文介绍了Android-打开电子邮件应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Android应用程序上打开电子邮件应用程序: 以下代码崩溃 我做错什么了吗?请提供代码

I want to open the email application on my android app: The following code crashes Am I doing anything wrong? please provide code

Intent i = new Intent (Intent.ACTION_SEND,Uri.fromParts("mailto", "testemail@gmail.com", null));
this.startActivity(i);

推荐答案

/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to@email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");

/* Send it off to the Activity-Chooser */
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

尝试一下,这更加清楚了.尽管如此,只有在真实电话中使用该应用程序时,才可以使用电子邮件,因此,如果您使用仿真器,请在真实电话中进行尝试.

Try this, it is a bit more clear. Nonetheless intent for emails only works if you are using the application in a real phone, so if you are using the emulator, try it on a real phone.

这篇关于Android-打开电子邮件应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆