2

我有一个问题,我正在尝试将 mp3 文件发送到 gmail。

到目前为止,我的代码适用于 whatsapp、hotmail、蓝牙……但它不适用于 gmail

这是我的代码:

File sdCard = Environment.getExternalStorageDirectory();
String path = sdCard.getAbsolutePath() + "/" +"miApp"+"/tono.mp3";

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("audio/mp3");
intent.putExtra(Intent.EXTRA_SUBJECT, "Asunto");
intent.putExtra(Intent.EXTRA_TEXT, "Prueba");
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///" + path));
startActivity(intent);

我尝试使用各种类型的 mime,但结果相同

  • “音频/x-mpeg-3”
  • “视频/mpeg”
  • “视频/x-mpeg”
  • “音频/mpeg”

怎么了?

4

1 回答 1

0

这对我有用

Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("audio/mp3");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/miApp/tono.mp3"));
startActivity(i);
于 2012-11-27T08:12:11.777 回答