send a jpg image throug MMS using HTC

954 Views Asked by At

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"

2

There are 2 best solutions below

4
starscream_disco_party On

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:

0
Harshid On

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