意图发送电子邮件打开驱动器不是gmail在某些设备上,虽然gmail安装



我有以下问题

当像这样启动一个意图时:

   final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
   emailIntent.setType("text/plain");
   emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "hello");     
   emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
   // uris is a ArrayList<Uri> that links to some images in the asset folder
   // everything works fine with those attachments on the nexus 4
   emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
   this.startActivity(emailIntent);

它向我展示了一组适合我的Nexus 4(运行4.2.2)的应用程序

如果我在Nexus 7(运行4.2.2)上运行代码,它不会显示我使用gmail的选项,即使它已经安装并运行良好。

对此有什么想法吗?

我能想到的唯一真正的区别是,nexus 7在设备上设置了两个用户帐户。这和问题有关吗?

试试这个:这对我有用!根据您的需要进行修改!

Uri file_uri = Uri.fromFile(fileLocation);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_SUBJECT, "");
i.putExtra(Intent.EXTRA_TEXT   , "");
i.putExtra(Intent.EXTRA_STREAM, file_uri);
try {
    startActivity(Intent.createChooser(i, "Complete Action Using"));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(ExportReport.this, "There are no email clients installed",Toast.LENGTH_SHORT).show();
}

最新更新