Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. public void onClick(View v) {
  2. if (v == btnSend) {
  3. String url = "http://app.xyz.com/api/SendMail/SendMail?Emailid=xyz@gmail.com" + "&Subject=" + "&Body=";
  4. if (url != null) {
  5. email = editTextEmail.getText().toString();
  6. subject = editTextSubject.getText().toString();
  7. message = editTextMessage.getText().toString();
  8. final Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND);
  9. emailIntent.setType("plain/text");
  10. emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
  11. new String[]{"xyz@gmail.com"});
  12. emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject);
  13. emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
  14. this.startActivity(Intent.createChooser(emailIntent, "Sending email..."));
  15.  
  16. }
  17. }catch (Throwable t) {
  18. Toast.makeText(this,
  19. "Request failed try again: " + t.toString(),
  20. Toast.LENGTH_LONG).show();
  21. }
  22. }
  23.  
  24. public void onCreate(Bundle savedInstanceState)
  25. {
  26. super.onCreate(savedInstanceState);
  27. setContentView(R.layout.feed_back);
  28. scanBtn = (Button) findViewById(R.id.button1);
  29. myAwesomeTextview = (TextView) findViewById(R.id.myAwesomeTextview);
  30. scanBtn.setOnClickListener(new View.OnClickListener()
  31. {
  32. public void onClick(View view)
  33. {
  34. mEdit = (EditText) findViewById(R.id.editText1);
  35. mText = (TextView) findViewById(R.id.textView2);
  36. Subject = mEdit.getText().toString();
  37. mEdit1 = (EditText) findViewById(R.id.editText2);
  38. mText1 = (TextView) findViewById(R.id.textView3);
  39. Body = mEdit1.getText().toString();
  40. Log.d("###$Request URL", Subject + "");
  41. Log.d("###$Request URL", Body + "");
  42. SharedPreferences sharedpreferences = getSharedPreferences(main.MyPREFERENCES, Context.MODE_PRIVATE);
  43. String e = sharedpreferences.getString(main.email,"");
  44. String url ="http://app.xyz.com/Api/SendMail/SendMail?Emailid="+ e + "&Subject="+ Subject+"&Body=" +Body;
  45. AQuery mAQuery = new AQuery(FeedBack.this);
  46. mAQuery.ajax(url, String.class, new AjaxCallback<String>()
  47. {
  48. @Override
  49. public void callback(String url, String data, AjaxStatus status)
  50. {
  51. super.callback(url, data, status);
  52. if (BuildConfig.DEBUG)
  53. {
  54. Log.d("###$Request URL", url + "");
  55. Log.d("###$Response ", data + "");
  56. Log.d("###$Status Message : ", status.getMessage() + "");
  57. Log.d("###$Status Code : ", status.getCode() + "");
  58.  
  59. }
  60. if(status.getCode()!=-101)
  61. {
  62. String StringData = "" + data;
  63. try
  64. {
  65. JSONObject json = new JSONObject(StringData);
  66. String sd,hd;
  67. sd = json.getString("Subject");
  68. hd= json.getString("Body");
  69.  
  70. }
  71. catch (Exception a)
  72. {
  73. Toast toast = Toast.makeText(FeedBack.this,"Mail Sending", Toast.LENGTH_LONG);
  74. toast.setGravity(Gravity.CENTER, 0, 0);
  75. toast.show();
  76. }
  77. }
  78. else
  79. {
  80. Toast toast = Toast.makeText(FeedBack.this,"Please Check Your Internet Connection", Toast.LENGTH_LONG);
  81. toast.setGravity(Gravity.CENTER, 0, 0);
  82. toast.show();
  83.  
  84. }
  85. }
  86. });
  87. }
  88. });
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement