title: Error while sending SMS
body: <p>I'm writing code for sending SMS, but sending the SMS is failing. Additionally, sometimes my code has a crossed line and this warning: "The method sendTextMessage(String, String, String, PendingIntent, PendingIntent) from the type SmsManager is deprecated" </p>
  
  <pre><code>class MainActivity extends Activity implements OnClickListener{
  
      Button bSend;
      EditText Mobile, msg;
      String mob, s_msg;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          init();
          bSend.setOnClickListener(this);
      }
  
      private void init() {
          // TODO Auto-generated method stub
          bSend = (Button) findViewById(R.id.bSendSMS);
          Mobile = (EditText)findViewById(R.id.etMobile);
          mob = Mobile.getText().toString();
          msg = (EditText)findViewById(R.id.etMsg);
          s_msg = msg.getText().toString();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
          try {
              SmsManager smsManager = SmsManager.getDefault();
              smsManager.sendTextMessage(mob, null, s_msg, 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>