How to send MMS using my code

陌路散爱 提交于 2020-01-14 06:09:12

问题


I've searched for couple days about sending 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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5011108/how-to-send-mms-using-my-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!