Send sms in android

by mariganesh 2013-03-04 18:14:16

Send sms in android


In MainActivity.java file


public class MainActivity extends Activity {
public EditText mnum,memail;
public TextView mUrlMessageResult;
private static final int MAX_SMS_MESSAGE_LENGTH = 160;
private static final short SMS_PORT = 0;
private static final Intent SMS_SENT = null;
private static final Intent SMS_DELIVERED = null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

}

public void searchInUrl(View clickedButton) {

mnum = (EditText)findViewById(R.id.mnum);
String mnumval= mnum.getText().toString();
memail = (EditText)findViewById(R.id.email);
String memailval= memail.getText().toString();
mUrlMessageResult = (TextView)findViewById(R.id.msg);

//Toast.makeText(getApplicationContext(), memailval+"-#"+mnumval, Toast.LENGTH_SHORT).show();
//showResults("http://192.168.0.19/test123.php");
MessageBox(memailval);
}
private void sendSMS(String phoneNumber, String message,Boolean isBinary )
{


try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null, message, 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();
}

}


}




in AndroidMainfest.xml



<uses-permission android:name="android.permission.SEND_SMS" />
962
like
0
dislike
0
mail
flag

You must LOGIN to add comments