How to send MMS without intent programmatically

2020-06-25 04:36发布

Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.png");
    Intent i = new Intent(Intent.ACTION_SEND);
    i.putExtra("address","1234567890");
    i.putExtra("sms_body","This is the text mms");
    i.putExtra(Intent.EXTRA_STREAM,"file:/"+uri);
    i.setType("image/png");
    startActivity(i);

I want to send MMS but I don't want to use intent object like above because I am developing my own application of sms manager. So how can I send MMS?

I am referring to this link code but I don't understand it and it doesn't work.

3条回答
来,给爷笑一个
2楼-- · 2020-06-25 05:10

Android's SmsManager API now supports this functionality since API level 21, with the sendMultimediaMessage method:

void sendMultimediaMessage (Context context, 
                Uri contentUri, 
                String locationUrl, 
                Bundle configOverrides, 
                PendingIntent sentIntent)
查看更多
Evening l夕情丶
3楼-- · 2020-06-25 05:24

MMS is a HTTP based request in Android. You have to have mobile data to send an MMS. There are no APIs exposed by Android to send an MMS, as they have APIs for SMS. If you want your application to send MMS you will have to write everything. Please refer the AOSP code. https://github.com/android/platform_packages_apps_mms OR you can simply build the Intent and then launch the native Messaging App.

查看更多
闹够了就滚
4楼-- · 2020-06-25 05:28

There is no public API to send an MMS in Android at the moment.

查看更多
登录 后发表回答