以编程方式发送彩信

Gee*_*thu 7 android mms

我想以编程方式发送MMS,我使用了以下代码

    Intent sendIntent1 = new Intent(Intent.ACTION_SEND); 
    try {

        sendIntent1.setType("text/x-vcard");
        sendIntent1.putExtra("address","0475223091");
        sendIntent1.putExtra("sms_body","hello..");
        sendIntent1.putExtra(Intent.EXTRA_STREAM,
                Uri.parse(vcfFile.toURL().toString()));
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    startActivity(sendIntent1);
Run Code Online (Sandbox Code Playgroud)

问题是它指向撰写消息页面,并需要手动发送短信,我不想这样,没有任何通知它应该发送我怎么能这样做?

SomeBody请与我分享答案

Def*_*era 9

我终于找到了一个100%有效的解决方案.请参考github项目https://github.com/klinker41/android-smsmms.(任何发现它有用的人请捐赠给作者http://forum.xda-developers.com/showthread.php?t=2222703).

请注意,强制性设置仅限于此

Settings sendSettings = new Settings();

sendSettings.setMmsc(mmsc);
sendSettings.setProxy(proxy);
sendSettings.setPort(port);
Run Code Online (Sandbox Code Playgroud)

你可以得到类似的东西(通过vincent091 在Android上编程方式找到Set APN):

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));
Run Code Online (Sandbox Code Playgroud)