通过 Facebook、电子邮件和 SMS/MMS 共享音频文件 (.mp3) [英] Share audio file (.mp3) via Facebook, email, and SMS/MMS
问题描述
我有一个音频文件 (.mp3) 和一些与之相关的信息.我想与 Facebook、电子邮件、短信/彩信等分享.
I have an audio file (.mp3) and some information related to it. I want to share with Facebook, E-mail, SMS/MMS, etc..
我所做的是:当用户单击共享按钮时,它会弹出可以处理此 Intent 的所有受支持应用程序的列表.但这不会显示 Facebook 和 SMS/MMS 选项.
What I have done is: when user clicks on the share button, it pops up list of all supported applications that can handle this Intent. But this does not show Facebook and SMS/MMS options.
这是我的代码..
public void shareWithFriends(int resId)
{
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/mp3");
share.putExtra(Intent.EXTRA_SUBJECT,"Ringtone File : "+ getResources().getResourceEntryName(resId)+".mp3");
share.putExtra(Intent.EXTRA_TEXT,"Ringtone File : "+getResources().getResourceEntryName(resId)+".mp3");
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("android.resource://com.my.android.soundfiles/"+resId));
share.putExtra("sms_body","Ringtone File : "+ getResources().getResourceEntryName(resId)+".mp3");
startActivity(Intent.createChooser(share, "Share Sound File"));
}
以下是一些结果:
当我使用 MIME 类型
audio/mp3
时,只弹出电子邮件选项.没有 Facebook 和短信/彩信共享.
When I use MIME type
audio/mp3
, only the email options pops up. No Facebook and SMS/MMS share.
当我使用 MIME 类型 */*
时,会弹出电子邮件和短信选项.没有 Facebook 选项.
When I use MIME type */*
, Email and SMS options pops up. No Facebook option is there.
这里有趣的是,当我单击 SMS 选项时,只显示文本.我没有看到任何附加的 MP3 文件(同样的事情发生在 Whatsapp(因为我在手机上安装了 Whatsapp).但是,当我点击任何邮件应用程序时(例如,Gmail 或 Yahoo 邮件)它向我显示了附加的 MP3 文件.
Here it is interesting to note that when I click on the SMS option, only text appears. I don't see any MP3 file attached (the same thing happens in Whatsapp (as I have Whatsapp installed on my phone). However, when I click on any mail application (for example, Gmail or Yahoo mail) it shows me the MP3 file attached.
我哪里出错了?
推荐答案
Facebook 没有选项,但您可以通过蓝牙共享电子邮件和彩信.这是我的代码.看看它是否对您有帮助:
There is no option for Facebook, but you can share email and MMS with Bluetooth. Here is my code. Take a look if it helps you:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///"+mypath));
startActivity(Intent.createChooser(share, "Share Sound File"));
break;
这里我的路径是SD卡上声音文件的路径.
Here my path is the path of the sound file on the SD card.
这篇关于通过 Facebook、电子邮件和 SMS/MMS 共享音频文件 (.mp3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!