Is there any api is available to send sms through internet in android

10,723

The term you are looking is SMS gateway.. Twilio API is working well with android, or you can use some other as per your wish..

Best is Bulk SMS. First Register here and then use your user name and password as shown in the example

Example:

import java.net.*;
import java.io.*;

public class SendSms {

static public void main(String[] args) {
    try {
        // Construct data
        String data = "";
        data += "username=" + URLEncoder.encode("your username", "ISO-8859-1");
        data += "&password=" + URLEncoder.encode("password", "ISO-8859-1");
        data += "&message=" + URLEncoder.encode("your message", "ISO-8859-1");
        data += "&want_report=1";
        data += "&msisdn=44123123123";// relace with the number

        // Send data
        URL url = new URL("http://bulksms.vsms.net:5567/eapi/submission/send_sms/2/2.0");

        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(data);
        wr.flush();

        // Get the response
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
            // Print the response output...
            System.out.println(line);
        }
        wr.close();
        rd.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}
Share:
10,723
user2918549
Author by

user2918549

Updated on June 04, 2022

Comments

  • user2918549
    user2918549 almost 2 years

    I am making an app in which i am have to send sms to another number using internet but i donot want to use phone native api i.e.smsManager means i donot want to pay for sms to mobile operator That means. i want to use Internet to send messages.like twillo and nexmo but iam unable to use this api in my android app. if iam using this api in my android the application is crashing so if any api is there please suggest me. or any other references are there to send sms through internet. or by using webservices

  • user2918549
    user2918549 over 10 years
    do you have any tutorial for that or sample program. for send sms through twilio in android.
  • Linga
    Linga over 10 years
    you can download it from twilio itself. they give java api. you can use it
  • user2918549
    user2918549 over 10 years
    I used with java api but application crashed
  • user2918549
    user2918549 over 10 years
    i changed following link gist.github.com/kwhinnery/5254045. program according to my requirement. it worked well in normal java program. but android it crashed
  • Linga
    Linga over 10 years
    I've edited my answer check it
  • user2918549
    user2918549 over 10 years
    will it work with android also
  • user2918549
    user2918549 over 10 years
    Thanks. I will check. Because i registered But not got any activation code