friends. I have a problem with my volleyball POST request with parameters. I need to get data from my remote MySQL database and display it as recyclers. For this, I have a volleyball net request. Without parameters, it loads all the data from my database. But when I add the getParams () method, it returns a null array, even if the corresponding DB records are available according to the transfer parameters. Here is my code ..
public void setDonorsList(final VolleyCallBack volleyCallBack) { if (Utility.isNetworkEnabled) { final ArrayList<Donor> listOfDonors = new ArrayList<>(); final ProgressDialog progressDialog = new ProgressDialog(FindDonorResult.this); progressDialog.setMessage("Loading Donors List. Please wait"); progressDialog.show(); StringRequest stringRequest = new StringRequest(Request.Method.POST, Constants.GET_DONORS_URL, new Response.Listener<String>() { @Override public void onResponse(String response) { progressDialog.dismiss(); try { listOfDonors.clear(); JSONArray jsonArray = new JSONArray(response); int count = 0; while (count < 10) { JSONObject jsonObject = jsonArray.getJSONObject(count); Donor donor = new Donor( jsonObject.getString("fName"), jsonObject.getString("sName"), jsonObject.getString("emailid"), jsonObject.getString("pass"), jsonObject.getString("mobile"), jsonObject.getString("blood"), jsonObject.getString("age"), jsonObject.getString("gender"), jsonObject.getString("country"), jsonObject.getString("location"), jsonObject.getString("latitude"), jsonObject.getString("longitude"), jsonObject.getString("picname"), jsonObject.getString("pic") ); int roundedDistance = (int) distance(Double.parseDouble(donor.getLatitude()), Double.parseDouble(latitude), Double.parseDouble(donor.getLongitude()), Double.parseDouble(longitude)); donor.setDistance(roundedDistance); listOfDonors.add(donor); count++; } Log.e("listOfDonors", String.valueOf(listOfDonors.size())); volleyCallBack.onSuccess(listOfDonors); } catch (JSONException e) { e.getMessage(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { error.getMessage(); } } ){ @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("bloodGroup", "A+"); return params; } }; NetworkRequestSingleTon.getOurInstance(FindDonorResult.this).addToRequestQue(stringRequest); } else { Toast.makeText(FindDonorResult.this, "No active internet connection.", Toast.LENGTH_SHORT).show(); } }
android mysql android-volley
Shibin kalliatt
source share