Advertisement
Guest User

Untitled

a guest
May 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1.     public String jsonResponse;
  2.  
  3.     public void GetDBInformation(String infoType) {
  4.         String GetURL = "";
  5.  
  6.         if (infoType.equals("Specie"))
  7.             GetURL = "http://apigeoma.novohorizonte.sp.gov.br/Api/Especies";
  8.         else if (infoType.equals("City"))
  9.             GetURL = "http://apigeoma.novohorizonte.sp.gov.br/Api/Cidades";
  10.         else if (infoType.equals("Street"))
  11.             GetURL = "http://apigeoma.novohorizonte.sp.gov.br/Api/Ruas";
  12.         else if (infoType.equals("Recommendation"))
  13.             GetURL = "http://apigeoma.novohorizonte.sp.gov.br/Api/Recomendacoes";
  14.  
  15.         StringRequest stringRequest = new StringRequest(Request.Method.GET, GetURL,
  16.                 new Response.Listener<String>() {
  17.                     @Override
  18.                     public void onResponse(String response) {
  19.                         jsonResponse = response;
  20.  
  21.                         CharSequence text = "Response: " + response;
  22.                         int duration = Toast.LENGTH_SHORT;
  23.  
  24.                         Toast toast = Toast.makeText(ctx, text, duration);
  25.                         toast.show();
  26.                     }
  27.                 },
  28.                 new Response.ErrorListener() {
  29.                     @Override
  30.                     public void onErrorResponse(VolleyError error) {
  31.                         CharSequence text = "Erro Voley!";
  32.                         int duration = Toast.LENGTH_SHORT;
  33.  
  34.                         Toast toast = Toast.makeText(ctx, text, duration);
  35.                         toast.show();
  36.                     }
  37.                 });
  38.  
  39.         RequestQueue requestQueue = Volley.newRequestQueue(ctx);
  40.         requestQueue.add(stringRequest);
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement