Intent.ACTION_SEND的WhatsApp [英] Intent.ACTION_SEND Whatsapp

查看:231
本文介绍了Intent.ACTION_SEND的WhatsApp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着通过WhatsApp的分享一个MP3文件。它可以完美地与其他应用程序如Gmail,但它dosent在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()?

下面是我的code:

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆