I am trying to send an image via an MMS using the following code
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "Hi there");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");
It opens the Messaging apps and attach the message but it did not write the "sms_body" which is in my case "Hi there". Why?
try this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
intent.putExtra("subject", "subject");
intent.putExtra("sms_body", "Hi there");
intent.putExtra("address", "Phonenumber");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
intent.setType("image/png");
startActivity(intent);
What seems to be working well is I just added EXTRA_TEXT (a solution which #yasserbn provided in a comment):
intent.putExtra(intent.EXTRA_TEXT, default_message);
in addition to:
intent.putExtra("sms_body", default_message);
And it seems to work whether it gets converted to multimedia message or sent as regular SMS.
Related
I'm trying to send an multimedia message(with an image) through an intent.How should I build the intent?
I've tried the code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
I can select mms app(Textra) from chooser dialog to send the image. But the chooser dialog lists other apps(such as Google Keep).
Then I tried this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
Only mms apps appears now.But I don't know how to attach my image.
Is there any solution for that?
try this may help,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
intent.putExtra("sms_body", "write some text here");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/whatever.png")));
intent.setType("image/*");
startActivity(intent);
Try this way,hope this will help you to solve your problem.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "some text");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
intent.setType("image/png");
startActivity(intent);
How send mms with attach in Android 4.0+? I try like:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/png");
sendIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse(outputFile.toURL().toString()));
startActivity(sendIntent);
It is work good in htc and samsung, but it is do not work in Nexus 5 (hangouts). I try like:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("address", phonesBuilder2.toString());
sendIntent.putExtra("sms_body", editTextTPMessage.getText());
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(makePicture()));
But file is not attach. I try very much ways, but all ways have problem.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "Hi how are you"); //Version dependent
intent.putExtra(Intent.EXTRA_TEXT, "Hi how are you"); //Version dependent
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif")));
intent.setType("image/gif");
startActivity(Intent.createChooser(intent,"Send"));
I am trying to send a jpg image through MMS using an HTC device (2.3.5, HTC Desire HD-Sense), I am using the following snippet
File sendfilepath = new File("file://" + sendfile);
Uri urimms = Uri.fromFile(sendfilepath);
Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
sendIntent.putExtra(Intent.EXTRA_STREAM, urimms);
sendIntent.setType("image/jpeg");
startActivity(sendIntent);
It opens the Messaging app but it does not attach the image. I do not know why? It shows a toast "Cannot load message"
Something like this should work:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mmsto:<number>");
intent.putExtra("address", <number>);
intent.putExtra(Intent.EXTRA_STREAM, urimms);
intent.setType("image/jpeg");
startActivity(intent);
Otherwise these links look to be a little outdated but you should be able to translate everything pretty well:
Android MMS Intent with with Image and body text
http://androidforums.com/application-development/25988-send-image-action_send.html
try this
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/image_4.png"));
sendIntent.setType("image/png");
startActivity(sendIntent);;
I have following code, which invoke mms client and attaches to it a picture
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra("address", phoneNumber);
sendIntent.putExtra(Intent.EXTRA_STREAM, mCurrItemUri);
sendIntent.setType("image/*");
getContext().startActivity(
Intent.createChooser(sendIntent, "Send MMS..."));
The problem I am facing is that I cannot pass phone number to that intent.
And Is there any way to pass an array of phone numbers to it?
Thank you on advance.
I think you need to set proper type for mms. for example:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
...
...
For more info, read this.
I have a custom file type (MIME_TYPE), basically xml, that I'd like to enable users to send to each other. Implementing the email send feature with the xml file as an attachment was straight forward but I'm kinda stuck on the SMS/MMS send feature. Anyone have any guidance?
final Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mms://"));
intent.setType("text/plain");
intent.putExtra("address", "2125551212");
String url = "content://myFile.txt";
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
intent.putExtra("sms_body", "some text goes here");
startActivityForResult(Intent.createChooser(intent, "mms-sms:"), SENT_TEXT);
the intent.putExtra(Intent.EXTRA_STREAM... doesn't seem to work, I get an error message:
"UNABLE TO ATTACH. FILE NOT SUPPORTED"
try this its worked with me for Send Photo.
use
Uri.fromFile
instead of
Uri.parse
File f=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/Camera/"+img_name);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("", "");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
sendIntent.setType("image/png");
startActivity(sendIntent);