我试着这样说:如何在Android Studio中将声音分享给whatsapp?
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文件位于在原始文件夹中
哪里是你的音频文件在什么位置? – jagapathi
@jagapathi在原始文件夹 – PentaGames