java如何在Android Studio中与whatsapp共享声音?
我这样试过:
shareBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent shareIntent = new Intent(安卓.content.Intent.ACTION_SEND);
shareIntent.setType("audio/mp3");
shareIntent.putExtra(安卓.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"
我的声音。mp3文件位于原始文件夹中
# 1 楼答案
您可以使用此代码共享原始文件夹文件