1

How can I send a picture from android application via MMS? I found this code but I don't know how can I insert picture inside it specially I want to let my application send the MMS. I do not want to send it via another application.

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");

1 Answers1

0

In this line sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url)); the second argument must be Uri that indicates where your image store

Like this: Uri myUri = Uri.parse("content://media/external/images/1")

And useful samples you can find here: forum topic

budgie
  • 315
  • 3
  • 12
  • so when i put 'Uri myUri = Uri.parse("content://media/external/images/1")' instead of 'sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));' it will send it from my application? –  Feb 26 '12 at 18:53
  • you must put Uri with existing on your device image – budgie Feb 26 '12 at 18:55
  • or in your case, you should to prepare url with image – budgie Feb 26 '12 at 18:57
  • can you explain more? i do not get it –  Feb 26 '12 at 18:57
  • how can i do it,please can you tell me? –  Feb 26 '12 at 18:57
  • i will let user fill the form (image,name,age...)then the user click finish then i will send it to unique number, it is all inside my application, how can i do it? –  Feb 26 '12 at 18:59
  • my question is how can i send the image via MMS from my application?i hope i get replay from you –  Feb 26 '12 at 19:01
  • oh, you don't know how extract image from url? if yes then try `Bitmap image = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());` – budgie Feb 26 '12 at 19:04
  • sorry, i am just beginner who should doing complete application on 2 weeks :( thank you for your answer, so Bitmap image = BitmapFactory.decodeStream((InputStream)new URL(url).getContent()); i should put it before '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");' –  Feb 26 '12 at 19:09
  • stop. this doesn't work `sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));`?)) you just need pass your image url – budgie Feb 26 '12 at 19:10
  • so the code is: `Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra("sms_body", "some text"); sendIntent.setType("image/png"); BitmapFactory.decodeStream((InputStream)new URL(url).getContent());` –  Feb 26 '12 at 19:17
  • note: the user will take the picture from Gallary, sorry i did not mention that earlier –  Feb 26 '12 at 19:21
  • can please please help me, i am really confuse! i need to complete code to send image -the user will choose it from gallery-via MMS on my application. I am sorry if i bothering you but i will appreciate it –  Feb 26 '12 at 19:34
  • from gallery that you create or users gallery? – budgie Feb 27 '12 at 06:28
  • from SD card the default gallery –  Feb 29 '12 at 15:38
  • so, take path of image [get file path from gallery image](http://www.androidsnippets.com/get-file-path-of-gallery-image). be sure that your path looks like this `"content://media/external/images/1"` and send mms – budgie Mar 02 '12 at 07:52