Sending sound file with a SMS Intent? - android

I have this code to fire SMS Intent :
String uri= "smsto:";
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
smsIntent.putExtra("sms_body", msgText);
smsIntent.putExtra("compose_mode", true);
startActivity(smsIntent);
I want to attach a sound file (.amr file) to the message. This file is in the raw folder.
Can I do this? and how?

Take a look at this for how to send an MMS and this to see how to get a stream to provide to the MMS intent.

Related

Android Facebook Messenger intent not working

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;

How to send recorded voice in email?

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.

Android Email vs MMS Raw Attachment?

I have this code to send an emai with an audio attachment that is coming from the raw folder:
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("Audio/basic");
i.putExtra(Intent.EXTRA_SUBJECT, "mySubject");
i.putExtra(Intent.EXTRA_TEXT, "myBody");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://[my_package]/raw/sound"));
startActivity(i);
This code works fine.
I tried to adapt the same code so that I can send MMS message with audio attachment from the raw folder.
I came up with this:
String uri= "mmsto:";
Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
i.putExtra("sms_body", "myBody");
i.putExtra("compose_mode", true);
i.putExtra(Intent.EXTRA_STREAM, Uri.parse"android.resource://[my_package]/raw/sound"));
startActivity(i);
The code opens an SMS application. However, there isn't any attachment to the message !
Am I doing it right? Please help me with that.
To those who might be interested:
MMS Functionality is a bit unreliable, not well-documented feature in Android. So, the existed solutions are supposed to work but they will not work all the time on all the devices. You can't depend on them, yet.

Sending MMS using buttonClick in Android without the UI.Is this possible?

Can i use only a button Click for sending MMS disabling UI?
Is this possible using Intent.ActionSENDTO
Help me!
Regards.
to send an MMS then use this code snippet:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");
here uri is path of your file. plus you can also define the number on which you want to send this mms

MMs code for android

How to Attach video file to my application , and how to show video in videoview ?
have any idea about send sms with attached videofile means(mms) in android?
if possible , any body give me the Sample code about it??
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("video/mpeg");
That should be all you need.

Categories

Resources