I am trying to create an intent that will start the MMS application for me with an image file attached and some pre-defined text present in the message body.
Thus far I've been able to accomplish either or, but not both at the same time.
Things I've tried (with their results):
sendIntent = new Intent(android.content.Intent.ACTION_SEND,Uri.parse("mms://"));
sendIntent.setType("image/gif");
sendIntent.putExtra(Intent.EXTRA_STREAM, imgStreamUri);
sendIntent.putExtra("sms_body", "HelloWorld");
startActivity(Intent.createChooser(sendIntent,"Send"));
/**********
Image file is attached but no text added to message body.
**********/
sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.setType("image/gif");
sendIntent.putExtra(Intent.EXTRA_STREAM, imgStreamUri);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "HelloWorld");
sendIntent.putExtra(Intent.EXTRA_TITLE, "WorldHello");
startActivity(Intent.createChooser(sendIntent,"Send"));
/**********
Image file is attached but no text added to message body(or subject or anything).
**********/
Does anyone know how I can attach both body text and an image file to an mms intent that will launch the default messaging application with the appropriate items filled in?
EDIT: Tested the code @lenik provided in answer. It is working on some devices, here's what I found
Works correctly:
Image attached but no text:
Anyone know if I am basically s.o.l. on the devices that don't work properly this way?
The following code works for me:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "Hi how are you");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif")));
intent.setType("image/gif");
startActivity(Intent.createChooser(intent,"Send"));