从android&发送短信日食

时间:2015-05-26 14:47:00

标签: android sms

我试图将短信从一个模拟器发送到另一个模拟器, 我有3个字符串,然后我将这3个字符串添加到一个字符串&然后尝试发送短信,但它只是发送'null'。

private String fm = mSelectedItemExam+" "+mSelectedItemBoard+" "+mSelectedItemYear;

public void Submit(View view) {      
     // sendSMS function
     sendSMS("5556", fm);
}

private void sendSMS(String phoneNumber, String message)
{
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, null, null);
}

检查Screenshot以查看我在其他模拟器上收到的内容

3 个答案:

答案 0 :(得分:4)

  Log.i("Send SMS", "");



            String phoneNo = "1212";
            String message = "msms";


               SmsManager smsManager = SmsManager.getDefault();
               smsManager.sendTextMessage(phoneNo, null, message, null, null);

答案 1 :(得分:3)

试试这个:

        Intent sendIntent = new Intent(Intent.ACTION_VIEW);
        sendIntent.putExtra("sms_body", "default content"); 
        sendIntent.setType("vnd.android-dir/mms-sms");
        startActivity(sendIntent);

答案 2 :(得分:1)

试试这个,

public void Submit(View view) {

     private String fm = mSelectedItemExam+" "+mSelectedItemBoard+" "+mSelectedItemYear;

     // sendSMS function
     sendSMS("5556", fm);
}

private void sendSMS(String phoneNumber, String message)
{
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, null, null);
}