Guest User

Untitled

a guest
Sep 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. How do you to implement Android 4.0 Restful, HTTP post request
  2. private OnClickListener login = new OnClickListener() {
  3.  
  4. public void onClick(View view) {
  5.  
  6. AsyncHttpClient myClient = new AsyncHttpClient();
  7. myClient.get(URL, null);
  8. myClient.setCookieStore(myCookieStore);
  9. myClient.setCookieStore(myCookieStore);
  10. String username = "";
  11. String password = "";
  12. RequestParams params1 = new RequestParams();
  13. params1.put("username", username);
  14. params1.put("password", password);
  15. pd = ProgressDialog.show(this, "", "Signing In...");
  16. myClient.post(URL, params1,
  17. new AsyncHttpResponseHandler() {
  18. @Override
  19. public void onSuccess(String response) {
  20. System.out.println("response" + response);
  21. pd.dismiss();
  22. if (response.contains("<!--Authorized-->")) {
  23. }
  24. else {
  25. pd.dismiss();
  26. Context mContext = SigninActivity.this;
  27. notMatchDialog = new Dialog(mContext);
  28. notMatchDialog.setContentView(R.layout.loginfaileddialoglayout);
  29. notMatchDialog.setTitle("Login failed");
  30. dismissDialogButton = (Button) notMatchDialog.findViewById(R.id.dismissDialogButton);
  31. dismissDialogButton.setOnClickListener(dismissDialog);
  32. notMatchDialog.show();
  33. }
  34. }
  35.  
  36. @Override
  37. public void onFailure(Throwable e, String response) {
  38. // TODO Need to figure out different failures and try to help the user.
  39. }
  40. });
  41. }
  42. };
Add Comment
Please, Sign In to add comment