How to send MMS using my code
I've searched for couple days about sen开发者_运维问答ding MMS,all i can find is the intent.ACTION_SEND things.I'm building a messaging program and i really need this mms sending feature. Any tips about it? Is there any API for sending MMS?
If you have to send mms with any image then this code.
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);;
OR
If you have to send mms with audio or video file then used this.
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("address", "1213123123");
sendIntent.putExtra("sms_body", "if you are sending text");
final File file1 = new File(mFileName);
if(file1.exists()){
System.out.println("file is exist");
}
Uri uri = Uri.fromFile(file1);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("video/*");
startActivity(sendIntent);
any query please replay.
Why does not ACTION_SEND suit you? What exact functionality do you need?
Intent sendIntent = new Intent(Intent.ACTION_SEND,
Uri.parse("mms://"));
sendIntent.setType("image/jpeg");
String url = "file://sdcard//tmpPhoto.jpg";
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
startActivity(Intent.createChooser(sendIntent, "MMS:"));
Crude example, but even though as you see you may input any type of data there using MMS. You may also check this link, if you want more info: https://android.googlesource.com/platform/packages/apps/Mms
精彩评论