title: How to send an SMS from Android emulator to a cellphone
body: <p>I am trying to send an SMS to a cellphone but I have a problem: I can't receive a message but  the emulator tells me the message has been sent.</p>
  
  <p>Here is my code,</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.widget.Button;
  import android.widget.EditText;
  import android.telephony.SmsManager;
  import android.view.View.OnClickListener;
  import android.widget.Toast;
  import android.view.View;
  
  public class sendsms extends Activity {
    Button buttonSend;
    EditText textPhoneNo;
    EditText textSMS;
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.sending);
      buttonSend = (Button) findViewById(R.id.BTNSENDSMS);
      textPhoneNo = (EditText) findViewById(R.id.txtEnterNoSMS);
      textSMS = (EditText) findViewById(R.id.txtMsgSMS);
      buttonSend.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
          String phoneNo = textPhoneNo.getText().toString();
          String sms = textSMS.getText().toString();
          try {
            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(phoneNo, null, sms, null, null);
            Toast.makeText(getApplicationContext(), "SMS Sent!", Toast.LENGTH_LONG).show();
          } catch (Exception e) {
            Toast.makeText(getApplicationContext(),"SMS faild, please try again later!",Toast.LENGTH_LONG).show();
            e.printStackTrace();
          }
        }
      });
    }
  }
  </code></pre>
  
  <p>And My AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sdc"
    android:versionCode="1"
    android:versionName="1.0" &gt;
    &lt;uses-sdk android:minSdkVersion="12" /&gt;
    &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt;
  &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
      &lt;/activity&gt;
    &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>