Android Email vs MMS Raw Attachment? - android

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.

Related

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.

attach picture to email

Anyone knows how to attach images with
Intent intent = new Intent(Intent.ACTION_SENDTO);
I know how to do it with Intent.ACTION_SEND, but i would like to use SENDTO to remove the Bluetooth option for the user.
What i have works fine when not attaching the picture but when i use
intent.setData(pictureUri);
It tells me that there isn't any application to do the job.
Thank you for your help.
EDIT
Inserted the code that I have now. It "works fine" except that the image isn't getting attached.
Code
intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/html");
Uri uri = Uri.parse("mailto:?");
intent.setData(uri);
intent.putExtra(Intent.EXTRA_STREAM, picture);
intent.putExtra("subject", subject );
context.startActivity(Intent.createChooser(intent, "Share Via:"));
The picture is a Uri for a picture on the phone.
Anyone knows what can be the problem?
Try:
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pic));
According to the API docs, SENDTO expects a recipient in the data field, not an attachment.
By saying intent.setData(pictureUri), you're basically trying to send a message to the picture. See here.
SEND accepts attachments via extras, so you could try the same for SENDTO.
For example:
intent.putExtra(Intent.EXTRA_STREAM, pictureUri);

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

How to add .pdf extension when sending an attachment from Android?

I am trying to send a pdf as an attachment from Android. Here is the code:
String[] mailto = {"me#gmail.com"};
Uri uri = Uri.parse("android.resource://com.mywebsite.sendemail/raw/mypdf");
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "My Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "My Body");
emailIntent.setType("application/pdf");
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(emailIntent, "Send email using:"));
Now this works but the problem is that the attachment is called mypdf instead of mypdf.pdf. I cannot figure out how to send it with it's extension... That's what I need help with. Thanks.
I am unconvinced what you want will be possible, since you are pulling the PDF from a resource. If you copy the PDF to a local file (with the correct extension) and send that, you should get the extension in the resulting message. But straight out of the resource...I suspect there's no way to add the extension.
When ever I attempt to use the .putExtra methodology it always crashes my application with a "Force Close" message. If I use something like:
String mtUri = "mailto:someone#gmail.com?subject=Some Subject&body=Some text&";
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(mtUri));
startActivity(intent);
It seems to work fine. I do still have the problem of attaching a file and could use some help figurint out the "attachment=file:///..." syntax.
Thanks,

Sending MMS into different Android devices

I need to send MMS. Into my hero this code looks ugly but works:
Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
sendIntent.putExtra("address", toText);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
sendIntent.putExtra("sms_body", textMessage);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/jpeg");
startActivity(sendIntent);
But it seems to me that on the other devices it doesn't work at all.
I want to send directly to main messaging app without any choices(the better solution of course - direct from my app). Because not sure that all of them would handle it properly.
If anybody could recommend any third-party library I'll be appretiate.
Have you tried something like this (change to your need and add images etc...):
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mmsto:<number>");
intent.putExtra("address", <number>);
intent.putExtra("subject", <subject>);
startActivity(intent);
The above is the best I could come up with which works on HTC/Nexus/SE from 1.6 to 2.2.
send from your app ?
before startActivity, you can
intent.setClassName("your package name", "your class name");
startActivity(intent);
You could try something like this.Which will launches all the apps which can handle the intent.
intent.setAction(Intent.ACTION_SEND);
//In case of multiple file
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, <List of uris>);
intent.putExtra(Intent.EXTRA_STREAM, <singleUri>);
intent.setType("*/*");
startActivity(intent);

Categories

Resources