HTC Thunderbolt上的Android电子邮件多附件问题

24

我这里遇到了一个奇怪的情况。

我正在尝试使用以下代码发送多个附件的邮件。

Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND_MULTIPLE );
// emailIntent.setType( "plain/text" );
emailIntent.setType( "application/octet-stream" );
...
....
emailIntent.putParcelableArrayListExtra( Intent.EXTRA_STREAM, uris );

这个方法很好用,隐式意图机制可以显示出很多选项,如Gmail、Skype、Messaging等。

问题在于,在HTC Thunderbolt上默认的邮件客户端没有显示(但在其他设备上包括HTC Incredible S上运作正常)。

如果我尝试使用Intent.ACTION_SEND发送单个附件,则会显示默认的邮件客户端。我已经尝试了将内容类型设置为text/plain、appliation/octet-stream、message/rfc282等,但都不起作用。

我在这里漏掉了什么?


最后,我将所有附件打包成一个zip文件并上传该zip文件。 - Mahadevan Sreenivasan
你试过这个吗?https://dev59.com/v2455IYBdhLWcg3wFP9u - juanlugm
4个回答

1

0

这对我非常有效,一定要指定消息类型,这是Android操作系统知道使用哪个广播的方法。

     String email = "test@email.com";
    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] {email}); // could have multiple address
    intent.putExtra(Intent.EXTRA_SUBJECT, "Enter your subject here");
    intent.putExtra(Intent.EXTRA_TEXT, "message text as needed");
    ArrayList<Uri> arrayUri = new ArrayList<Uri>();
    arrayUri.add(Uri.parse("file://" + paths[0]));
    arrayUri.add(Uri.parse("file://" + paths[1]));
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, arrayUri);
    startActivity(Intent.createChooser(intent, "Any title to show on chooser"));

0

试试这个。我认为它会起作用。

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");

ArrayList<Uri> uris = new ArrayList<Uri>();

String[] filePaths = new String[] {image1 Path,image2 path};
for (String file : filePaths) {
    File fileIn = new File(file);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
}

if ( !(app_preferences.getString("email", "") == null || app_preferences.getString("email", "").equals(""))) {
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {app_preferences.getString("email", "")});    
}

emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject name");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Please find the attachment.");
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

startActivity(Intent.createChooser(emailIntent, "Email:"));

0

听起来像是Thunderbolt版本的Sense出现了bug。自定义用户界面厉害吧,对吧?

无论如何,我会查找在Thunderbolt上处理电子邮件的应用程序,并放置一个if语句来检测设备是否为Thunderbolt。如果是的话,将Intent的目标类设置为那个应用程序。如果不是,就继续做你已经在做的事情。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接