1

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"

Nate
  • 31,017
  • 13
  • 83
  • 207
yasserbn
  • 391
  • 3
  • 18

2 Answers2

0

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:

Community
  • 1
  • 1
starscream_disco_party
  • 2,816
  • 5
  • 26
  • 42
0

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);; 
Harshid
  • 5,701
  • 4
  • 37
  • 50