How to Send and Receive SMS through the application?

Bulk SMS service provider companies provide a facility to send and receive SMS through an application.
There are many applications which support android platform and have a capacity of sending SMS/MMS messages. Once your application is started running then you can add the capacity to communicate with the outside world. If you want that your application can send an SMS to another phone or you may wish to access a Web service that provides certain services then you can send it through an application. In this article, we will tell you how to send and receive SMS programmatically within your Android applications. You will also learn how to use HTTP protocol to talk to web servers so that you can download data.

It is good to send SMS messages programmatically from your application. With the help of this approach, your application can automatically send an SMS message to a recipient without user involvement.

How to Send and Receive SMS through the application?

How to Send and Receive SMS through the application?

Steps to send and receive SMS through applications are:

1. Using Eclipse and create a new Android project

2. //Android SMS API integration code

//Your authentication key
String authkey = “YourAuthKey”;
//Multiple mobiles numbers separated by comma
String mobiles = “9999999”;
//Sender ID, While using route4 sender id should be 6 characters long.
String senderId = “102234”;
//Your message to send, Add URL encoding here.
String message = “Test message”;
//define route
String route=”default”;

URLConnection myURLConnection=null;
URL myURL=null;
BufferedReader reader=null;

//encoding message
String encoded_message=URLEncoder.encode(message);

//Send SMS API
String mainUrl=”https://control.msg91.com/api/sendhttp.php?”;

//Prepare parameter string
StringBuilder sbPostData= new StringBuilder(mainUrl);
sbPostData.append(“authkey=”+authkey);
sbPostData.append(“&mobiles=”+mobiles);
sbPostData.append(“&message=”+encoded_message);
sbPostData.append(“&route=”+route);
sbPostData.append(“&sender=”+senderId);

//final string
mainUrl = sbPostData.toString();
try
{
//prepare connection
myURL = new URL(mainUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));

//reading response
String response;
while ((response = reader.readLine()) != null)
//print response
Log.d(“RESPONSE”, “”+response);

//finally close connection
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}

Use the above code to send SMS through your android SMS

3 Once you created a new campaign to send the SMS, compose the SMS and it will be sent to the selected mobile numbers.

4 Select the route by which you want to send the SMS.

5 You can also schedule the SMS which you want to send to your customers in a particular time. For this, click on Schedule to send the SMS option and then set timing. After that click on “Confirm sending 1 SMS” to send the SMS.

6 Your SMS is successfully sent. You can also check the delivery report of your message campaigning.

In this way, you can send and receive bulk SMS through your application. Please note that always take SMS gateway and API from genuine service provider company so that you can target large audience in a short duration at an affordable price. If you found any problem in sending SMS then you can contact your service provider company, they will help you to resolve your problem. You can also contact us or drop your query in the comment section, we will try to solve your problem as soon as possible.