Send MMS from My application in android

大兔子大兔子 提交于 2019-12-03 01:43:42

why don't you use the android system functions:

Please have a look on

https://developer.android.com/guide/components/intents-common.html

public void composeMmsMessage(String message, Uri attachment) {
       Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setData(Uri.parse("smsto:"));  // This ensures only SMS apps respond
       intent.putExtra("sms_body", message);
       intent.putExtra(Intent.EXTRA_STREAM, attachment);
       if (intent.resolveActivity(getPackageManager()) != null) {
           startActivity(intent); }
}

Cheers

Tom

I found a link in an other thread to a github project that works 100% https://github.com/klinker41/android-smsmms

Notice, that obligatory settings are only

Settings sendSettings = new Settings();

sendSettings.setMmsc(mmsc);
sendSettings.setProxy(proxy);
sendSettings.setPort(port);

you can get them something like (found at Set APN programmatically on Android - answear by vincent091):

Cursor cursor = null;
if (Utils.hasICS()){
    cursor =SqliteWrapper.query(activity, activity.getContentResolver(), 
            Uri.withAppendedPath(Carriers.CONTENT_URI, "current"), APN_PROJECTION, null, null, null);
} else {
    cursor = activity.getContentResolver().query(Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"),
        null, null, null, null);
}

cursor.moveToLast();
String type = cursor.getString(cursor.getColumnIndex(Telephony.Carriers.TYPE));
String mmsc = cursor.getString(cursor.getColumnIndex(Telephony.Carriers.MMSC));
String proxy = cursor.getString(cursor.getColumnIndex(Telephony.Carriers.MMSPROXY));
String port = cursor.getString(cursor.getColumnIndex(Telephony.Carriers.MMSPORT));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!