0
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");           
smsIntent.putExtra("sms_body",sMessage);
startActivity(smsIntent);

它工作正常。但我想打开不可编辑的消息正文。用户只能选择他/她想要发送消息的号码

4

1 回答 1

2

你可以尝试不同的方式然后intent.Like直接使用sms到收件人的号码并在你自己的视图中显示消息。

将短信直接发送到电话号码的代码:

private void sendAutoSms(String phonenumber,String message, boolean isBinary)
{
SmsManager manager = SmsManager.getDefault();

PendingIntent intentSend = PendingIntent.getBroadcast(this, 0, new Intent(SMS_SENT), 0);
PendingIntent intentDelivered = PendingIntent.getBroadcast(this, 0, new Intent(SMS_DELIVERED), 0);

if(isBinary)
{
        byte[] data = new byte[message.length()];

        for(int index=0; index<message.length() && index < MAX_SMS_MESSAGE_LENGTH; ++index)
        {
                data[index] = (byte)message.charAt(index);
        }

        manager.sendDataMessage(phonenumber, null, (short) SMS_PORT, data,intentSend, intentDelivered);
}
else
{
        int length = message.length();

        if(length > MAX_SMS_MESSAGE_LENGTH)
        {
                ArrayList<String> messagelist = manager.divideMessage(message);

                manager.sendMultipartTextMessage(phonenumber, null, messagelist, null, null);
        }
        else
        {
                manager.sendTextMessage(phonenumber, null, message, intentSend, intentDelivered);
        }
}
}

在清单中包含权限

<uses-permission android:name="android.permission.SEND_SMS"/>
于 2013-03-20T06:53:27.617 回答