Intent.ACTION_SEND Whatsapp [英] Intent.ACTION_SEND Whatsapp
本文介绍了Intent.ACTION_SEND Whatsapp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过 whatsapp 共享 mp3 文件.它与 gmail 等其他应用程序完美兼容,但它不适用于 whatsapp.谁能帮我?我需要添加一些 putExtra() 吗?
Im trying to share a mp3 file through whatsapp. It works perfectly with other apps like gmail, but it dosent works on whatsapp. Can anyone help me? Do I need to add some putExtra()?
这是我的代码:
public void shareWithFriends(int id)
{
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/mp3");
//share.putExtra(Intent.EXTRA_SUBJECT,"subject");
//Uri uri = Uri.parse("android.resource://com.igs.pokemonsoundboard/" + id);
Uri uri = Uri.parse("android.resource://com.igs.pokemonsoundboard/raw/" + R.raw.pikachump3);
share.putExtra(Intent.EXTRA_STREAM,uri);
//share.putExtra("sms_body","Ringtone File :");
startActivity(Intent.createChooser(share, "Share sound"));
}
谢谢;)
推荐答案
您应该将音频文件复制到 SD 卡,并将其作为文件共享,而不是作为 android 资源共享,如下所示:
You should copy your audio file to sdcard, and share it as file, not as android resource, like this:
final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("audio/mp3");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://"+path+filename));
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_sound)));
现在它应该可以通过 whatsapp 工作了.
Now it should work through whatsapp.
这篇关于Intent.ACTION_SEND Whatsapp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文