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.smsManage
r 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
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();
}
}
}