Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. private Double balance;
  2.  
  3. public double getBalance(Address address){
  4. balance=0.0;
  5. String url = urlAPI+address.toString();
  6.  
  7. RequestQueue reqQueue;
  8. reqQueue = Volley.newRequestQueue(this);
  9.  
  10. JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, url, null,
  11. new Response.Listener<JSONObject>() {
  12. @Override
  13. public void onResponse(JSONObject response) {
  14. try {
  15.  
  16. if (response.get("data").toString() != "null") {
  17. balance = Double.parseDouble(response.get("data").toString()) / 100000000;
  18. } else {
  19. balance = 100.00000001;
  20. }
  21. ;
  22. } catch (JSONException e) {
  23. e.printStackTrace();
  24. }
  25. }
  26. },
  27. new Response.ErrorListener() {
  28. @Override
  29. public void onErrorResponse(VolleyError error) {
  30. }
  31. }
  32. );
  33.  
  34. reqQueue.add(jsonObjReq);
  35.  
  36. return balance;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement