//Android SMS API integration code

//Your Apikey
String apikey = "YourApikey"; //Approved sender id(6 characters string only).
String senderid = "TESTIN"; //Message channel Promotional=1 or Transactional=2
String channel = "2"; //Default is 0 for normal message, Set 8 for unicode sms
String DCS = "0"; //Default is 0 for normal sms, Set 1 for immediate display.
String flashsms = "0"; //Recipient mobile number (pass with comma seprated if need to send on more then one number). String mobile = "9999999"; //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://www.smsgatewayhub.com/api/mt/SendSMS?";
//Prepare parameter string
StringBuilder sbPostData= new StringBuilder(mainUrl);
sbPostData.append("apikey="+apikey);
sbPostData.append("&senderid="+senderid);
sbPostData.append("&channel="+channel);
sbPostData.append("&DCS="+DCS);
sbPostData.append("&flashsms="+flashsms);
sbPostData.append("&mobile="+mobile);
sbPostData.append("&mobile="+message);
sbPostData.append("&route="+route);

//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();
}