如何通过意图打开电子邮件程序(但只有一个电子邮件程序)电子邮件、程序、意图、但只

由网友(教主范)分享简介:我想设置我的应用程序的一部分,允许用户发送快速电子邮件给其他用户。这不是很难进行设置:I want to setup a part of my application that allows users to send a quick email to another user. It's not very har...

我想设置我的应用程序的一部分,允许用户发送快速电子邮件给其他用户。这不是很难进行设置:

I want to setup a part of my application that allows users to send a quick email to another user. It's not very hard to set this up:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
Intent mailer = Intent.createChooser(intent, null);
startActivity(mailer);

然而,问题是,ACTION_SEND被接受,不仅仅是电子邮件程序 - 例如,我的手机上的Facebook应用程序,微博,reddit的是有趣的,甚至是蓝牙拿出来发送这个消息作为可行的替代方案。该消息完全是太长,其中的一些(尤其是微博)。

However, the problem is that the ACTION_SEND is accepted by more than just email programs - for example, on my phone the Facebook app, Twitter, reddit is fun, and even Bluetooth come up as viable alternatives for sending this message. The message is entirely too long for some of these (especially Twitter).

有没有一种方法来选择器限制,以支持长信息(如电子邮件)只是应用程序?或者是有没有办法适当地检测到用户选择的应用程序,并调整消息?

Is there a way to limit the chooser to just applications that support long messages (such as email)? Or is there a way to detect the app that the user has chosen and adjust the message appropriately?

推荐答案

更​​改MIME类型就是答案,这就是我做我的应用程序更改相同的行为。我用 intent.setType(信息/ RFC822);

Changing the MIME type is the answer, this is what I did in my app to change the same behavior. I used intent.setType("message/rfc822");

阅读全文

相关推荐

最新文章