Hi guys I am new to programming. The code below is able predefined SMS to predefined number by pressing button but it will bring to the message composer screen and requires me to click send. How do I send the SMS directly without going to the message composer. I see few people are asking this too and one of the solution is using SMSmanger
but i do not know how to use SMSmanger
code into my code.
public class SendSMSActivity extends Activity {
Button buttonSend;
Button buttonSend2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
buttonSend = (Button) findViewById(R.id.buttonSend);
buttonSend2 = (Button) findViewById(R.id.buttonSend2);
OnClickListener listener = new OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.buttonSend:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "#abc");
sendIntent.putExtra("address", "9900990");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
break;
case R.id.buttonSend2:
Intent sendIntent1 = new Intent(Intent.ACTION_VIEW);
sendIntent1.putExtra("sms_body", "#def");
sendIntent1.putExtra("address", "9900990");
sendIntent1.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent1);
break;
}
}
};
buttonSend.setOnClickListener(listener);
buttonSend2.setOnClickListener(listener);
}
)
Thank you