1

认为,

我已经从模拟器向我的手机号码发送了一条短信,但我的手机没有收到任何消息。是否可以查看从“模拟器”在我的手机上发送的短信。如果可以,如何?

到目前为止,我已经做到了这一点,并将其敬酒为“发送短信”。请在下面找到我的来源

public class Send_sms extends Activity {

private static final String TAG = "Send_sms";
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main12);

    Button sndbtn =(Button)findViewById(R.id.but_send_ok);
    sndbtn.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) 
    {
        EditText addrTxt = (EditText)Send_sms.this.findViewById(R.id.editText_number);
        EditText msgTxt = (EditText)Send_sms.this.findViewById(R.id.editText_write_msg);
        try
        {
            sendSmsMessage(addrTxt.getText().toString(),msgTxt.getText().toString());
            Toast.makeText(Send_sms.this,"Sms sent",Toast.LENGTH_LONG).show();
        }
        catch(Exception e)
        {
            Toast.makeText(Send_sms.this,"Failed to send sms",Toast.LENGTH_LONG).show();
        }
    }});
}

@Override
protected void onDestroy() {

    super.onDestroy();
}
private void sendSmsMessage(String address,String message)throws Exception
{
    SmsManager smsMgr = SmsManager.getDefault();
    smsMgr.sendTextMessage(address,null,message,null,null);
}
}
4

2 回答 2

1

No it is not possible to send sms for emulator to real device because Emulator has a virtual device and a virtual device not able to communicate with a real device but you are able to send sms from a virtual device to another virtual device.

于 2012-06-04T06:57:42.203 回答
0

使用PendingIntent对象,无论短信发送成功还是失败,您都可以从 Android 系统接收通知。

为此,sendTextMessage()应设置的第 4 和第 5 个参数。在此处查看详细信息:在此处输入链接描述

有关工作示例,请查看: http: //mobiforge.com/developing/story/sms-messaging-android

于 2012-06-04T06:55:30.500 回答