Guest User

Untitled

a guest
Oct 28th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. private void sendSMS() {
  2. Handler handler = new Handler();
  3. Runnable r = new Runnable() {
  4. public void run() {
  5. try {
  6. // Construct data
  7. String username = "username=" + "bestfolio";
  8. String password = "&password=" + "12345678";
  9. String sendername = "&sendername=" + "AGPUBS";
  10. String mobileno = "&mobileno=" + mobile;
  11. String message = "&message=" + welcomeMessage;
  12. String url = "http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?";
  13.  
  14. // Send data
  15. String data = username + password + sendername + mobileno + message;
  16. HttpURLConnection conn = (HttpURLConnection) new URL(url + data).openConnection();
  17.  
  18. conn.setDoOutput(true);
  19. conn.setRequestMethod("POST");
  20. conn.setRequestProperty("Content-Length", Integer.toString(data.length()));
  21. conn.getOutputStream().write(data.getBytes("UTF-8"));
  22. final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  23. final StringBuffer stringBuffer = new StringBuffer();
  24. String line;
  25. while ((line = rd.readLine()) != null) {
  26. Log.e("SMS.......", "" + line);
  27. }
  28. rd.close();
  29.  
  30. //return stringBuffer.toString();
  31. } catch (Exception e) {
  32. Log.e("Error is", "" + e);
  33. }
  34. }
  35. };
  36. handler.postDelayed(r, 1000);
  37. }
Add Comment
Please, Sign In to add comment