Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. StringRequest jsonObjRequest = new StringRequest(Request.Method.POST, URL,
  2. new Response.Listener<String>() {
  3. @Override
  4. public void onResponse(String response) {
  5. System.out.println("hellooo");
  6. }
  7. }, new Response.ErrorListener() {
  8.  
  9. @Override
  10. public void onErrorResponse(VolleyError error) {
  11. System.out.println("error");
  12. }
  13. }) {
  14.  
  15. @Override
  16. public String getBodyContentType() {
  17. return "application/x-www-form-urlencoded; charset=UTF-8";
  18. }
  19.  
  20. @Override
  21. protected Map<String, String> getParams() throws AuthFailureError {
  22. Map<String, String> params = new HashMap<String, String>();
  23. params.put("username", "hello");
  24. params.put("password", "hellooo");
  25. return params;
  26. }
  27. };
  28.  
  29. queue.add(jsonObjRequest);
  30.  
  31. Retrofit retrofit = new Retrofit.Builder()
  32. .baseUrl(URL)
  33. .addConverterFactory(GsonConverterFactory.create())
  34. .build();
  35.  
  36. testAPI testapi = retrofit.create(testAPI.class);
  37.  
  38. String hello = "hello";
  39.  
  40. Call<Message> call = testapi.sendData(hello);
  41.  
  42. call.enqueue(new Callback<Message>() {
  43. @Override
  44. public void onResponse(Response<Message> response) {
  45. System.out.println(response);
  46. }
  47.  
  48. @Override
  49. public void onFailure(Throwable t) {
  50. System.out.println(t);
  51. }
  52. });
  53.  
  54. Ion.with(getContext())
  55. .load("https://koush.clockworkmod.com/test/echo")
  56. .setBodyParameter("goop", "noop")
  57. .setBodyParameter("foo", "bar")
  58. .asString()
  59. .setCallback(...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement