Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void sendSMS() {
- Handler handler = new Handler();
- Runnable r = new Runnable() {
- public void run() {
- try {
- // Construct data
- String username = "username=" + "bestfolio";
- String password = "&password=" + "12345678";
- String sendername = "&sendername=" + "AGPUBS";
- String mobileno = "&mobileno=" + mobile;
- String message = "&message=" + welcomeMessage;
- String url = "http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?";
- // Send data
- String data = username + password + sendername + mobileno + message;
- HttpURLConnection conn = (HttpURLConnection) new URL(url + data).openConnection();
- conn.setDoOutput(true);
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Content-Length", Integer.toString(data.length()));
- conn.getOutputStream().write(data.getBytes("UTF-8"));
- final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- final StringBuffer stringBuffer = new StringBuffer();
- String line;
- while ((line = rd.readLine()) != null) {
- Log.e("SMS.......", "" + line);
- }
- rd.close();
- //return stringBuffer.toString();
- } catch (Exception e) {
- Log.e("Error is", "" + e);
- }
- }
- };
- handler.postDelayed(r, 1000);
- }
Add Comment
Please, Sign In to add comment