I have an audio file (.mp3) and some information related to it. I want to share with Facebook, E-mail, SMS/MMS, etc..
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.
Here is my code..
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"));
}
Here are some results:
When I use MIME type audio/mp3, only the email options pops up. No Facebook and SMS/MMS share.
When I use MIME type */*, Email and SMS options pops up. No Facebook option is there.
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.
Where am I going wrong?
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;
Here my path is the path of the sound file on the SD card.
You are trying to share an mp3 over services that don't support it.
Facebook supports text, pictures and videos.
SMS is plain text (and only very short plain text)
MMS does support audio, but (as far as I can tell from observation (i.e. without reading the spec)) only very low bit rate audio in some format that usually comes in a file with a .3g extension
The apps do not show up in the list of supported apps for mp3 because they are not supported.
File f=new File("full audio path");
Uri uri = Uri.parse("file://"+f.getAbsolutePath());
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("audio/*");
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(Intent.createChooser(share, "Share audio File"));
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("audio/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,
Uri.fromFile(new File("filepath")));
startActivity(Intent.createChooser(sharingIntent,"Share using"));
You are try this.
final Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "bod of sms");
sendIntent.setType("*/*");
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"test.amr");
Uri uri = Uri.fromFile(file1);
Log.e("Path", "" + uri);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(sendIntent, ""));
Use following code its working for me to share audio via intent.
String path = Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/abc.mp3";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + path));
startActivity(Intent.createChooser(share, "Share Sound File"));
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"));
Related
Hi I want to share both text and pdf file at a time in whats app,How it can be done.currently i can share any one of them at a time.
I have tried this but its not working.
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.setType("application/pdf");
share.putExtra(Intent.EXTRA_TEXT, "My sample image text");
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setPackage("com.whatsapp");
startActivity(shareIntent);
I am trying to share an mp3 file with with an intent on Android.
The code that I am using is the following:
// uri creation
audioFile=Uri.parse("android.resource://" + getPackageName() + "/raw/audio" + albumArtResId);
// intent creation
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/mp3");
share.putExtra(Intent.EXTRA_STREAM, audioFile);
startActivity(Intent.createChooser(share, "Share Sound File"));
But after the selection of a specific contact in whatsapp a toast notification appears with the following message:"the file format is not supported".
I am quite sure that the problem is given by the URI creation but I have no ideas about how to solve it.
im trying to share audio file on facebook messenger. Following as mention https://developers.facebook.com/docs/messenger/android#integration_with_intents here but it work to share simple text not audio file. App crash when i try to send audio on messenger.
This is intent share code
String mimeType = "audio/aac";
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setPackage("com.facebook.orca");
intent.setType(mimeType);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(EXTRA_PROTOCOL_VERSION, PROTOCOL_VERSION);
intent.putExtra(EXTRA_APP_ID, YOUR_APP_ID);
this.startActivityForResult(intent, SHARE_TO_MESSENGER_REQUEST_CODE);
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;
I am develop one app that require record the voice.and that voice can be automatically attached to the mms.
i am useing this code
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("address", "9999999999");
sendIntent.putExtra("sms_body", "if you are sending text");
final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"connection.amr");
Uri uri = Uri.fromFile(file1);
Log.e("Path", "" + uri);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("*/*");
startActivity(sendIntent);
all of the going fine but file can't attached automatically.any idea about this??
When user click on send button that time automatically attached that file in particular number with subject and sms_body part that it.
My file Extension is .3gp
This code is perfect work in Samsung ace 5830i and Samsung Galaxy nexus but not work in Htc desire c,Htc one.
I am tested this setType.but not positive response.
sendIntent.setType("video/3gp");
sendIntent.setType("audio/*");
sendIntent.setType("*/*");
sendIntent.setType("audio/mp3");
If automatic attachement is possible or not?
Try this:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("text-body", "if you are sending text");
sendIntent.putExtra("num", "number");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("ur file path"));
sendIntent.setType("audio/3gp");
I am developing a Android Application, In which I need to send voice by email.
Ans I want that such flow,
record a voice and send mail as a audio file in attachment.
and I want that voice should not remaining in phone or SD card.
is it possible ?
Here is what you need, It works with me.......
Uri uri = Uri.fromFile(new File(YOUR_DIR, YOUR_FILE_NAME)));
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "TITLE");
it.putExtra(Intent.EXTRA_TEXT, "CONTENT");
it.putExtra(Intent.EXTRA_STREAM, uri);
it.setType("audio/rfc822");
context.startActivity(Intent.createChooser(it,context.getString(R.string.share)));
One of the solution according to me is..
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("audio/3gp");
startActivityForResult(Intent.createChooser(sendIntent, "Send mail..."),0);
with above code you can send the voice as email attachment and in the onActivityResult() you can delete the file from sdcard/memory.