在Android中将文本从应用程序共享到电子邮件应用程序 [英] Sharing text from app to Email app in android
问题描述
我有以下代码用于将文本从我的应用发送到电子邮件:
I have the following code which used to send text from my app to Email:
Intent mail = new Intent(Intent.ACTION_VIEW);
mail.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
mail.putExtra(Intent.EXTRA_EMAIL, new String[] { });
mail.setData(Uri.parse(""));
mail.putExtra(Intent.EXTRA_SUBJECT, "Country Decryption");
mail.setType("plain/text");
mail.putExtra(Intent.EXTRA_TEXT, "my text");
ctx.startActivity(mail);
它可以工作,但是如您所见,它使用Gmail应用程序,如何使用电子邮件应用程序而不是Gmail?
It works , but as you see, it uses Gmail app, how do I make it use Email application instead of Gmail?
我的意思是这个程序:
I mean this app:
该如何与Facebook分享呢?我发现Facebook不再支持使用Intent进行共享,而我不得不使用Facebook SDK,但是我找不到任何简单的过程来做到这一点.有什么简单的方法吗?
and what about sharing to Facebook ? I found that Facebook does not support sharing using intent anymore, and I have to use Facebook SDK, but I couldn't find any simple procedure to do that. Is there any simple way?
致谢.
推荐答案
很好地使用其他电子邮件应用程序,恐怕您将不得不创建选择器对话框并让用户选择要使用的应用程序,例如
well to use other email apps am afraid you would have to create a chooser dialog and let the user choose which app to use, something like this
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto","abc@mail.com", null));
emailIntent.putExtra(Intent.EXTRA_EMAIL, "address");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
startActivity(Intent.createChooser(emailIntent, "Send Email..."));
这篇关于在Android中将文本从应用程序共享到电子邮件应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!