I am working on how to send a MMS in android from my app.
i copied an image named image1.png to the sdcard folder in file explorer. its is located in mnt--> sdcard--> image1.png
i run the emulator and scanned the media and i can find the image in the gallery.
now to send the mms i used the following code
...................................................................................
Intent pic = new Intent(Intent.ACTION_SEND);
pic.putExtra("sms_body", "click the above image");
String url = "\\sdcard\\image1.png";
pic.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
pic.setType("image/png");
startActivity(pic);
...................................................................................
the emulator with the sdcard is already running and now when i run the application it opens up the mms apllication with a TO field and also 开发者_如何学编程with the sms body mentioned but the image is not attached.i get the following toast message on my screen
...................................................................................
"sorry you cannot add this picture to your message "
...................................................................................
can anyone help me with this issue?
and i dont understand the concept of uri. can someone help me out.
Many thanks
Change your code to
Intent pic = new Intent(Intent.ACTION_SEND);
pic.putExtra("sms_body", "click the above image");
String external = Environment.getExternalStorageDirectory().toString();
String path = "file://" + external + "/image1.png";
pic.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
pic.setType("image/png");
startActivity(pic);
So actually you need to pre-append the "file://"
精彩评论