【发布时间】:2017-06-22 00:37:36
【问题描述】:
我试过这样:
shareBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("audio/mp3");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://com.example.aaron.sharetest/sound.mp3"));
startActivity(Intent.createChooser(shareIntent, "Sound shared!"));
但这不起作用,whatsapp告诉我再试一次。
我在this stackoverflow question的回答中也发现了这种方式:
String sharePath = Environment.getExternalStorageDirectory().getPath()
+ "/Soundboard/Ringtones/custom_ringtone.ogg";
Uri uri = Uri.parse(sharePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Sound File"));
在我的情况下,我必须写什么来代替这个?:
Environment.getExternalStorageDirectory().getPath()
+ "/Soundboard/Ringtones/custom_ringtone.ogg"
我的 sound.mp3 文件位于 raw 文件夹中
【问题讨论】:
-
您的音频文件在哪里?
-
@jagapathi 在原始文件夹中
标签: java android audio resources share