I have tried the code to send the sms to fixed user But According to my functionality I want to send the sms which depends on flag.When flag is true then to send the sms directly.Now It is calling the Intent and goes to the sms screen and when there we click on send button then it will send the sms.But I dont want to come on this screen,I want to send sms directly to fixed user
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("sms:"
+ phoneNumber)));
And
String x="Hello World";
String y="You Rock!!!";
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", x);
sendIntent.putExtra("sms_body", y);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
You will have to use SMSManager class to send a message directly.
Use SmsManager.sentextMessage api in the above class
and add permission