Volley getting an error response
Asked Answered
C

1

2

I am sending some post data using volley. Here is my code . It's a snippet from background service. Let me know if you want other files also. I've added the internet permission.

    public void onLocationChanged(final Location location) {
        mCurrentLocation = location;
        pref.setLocation(location);

        String url = getResources().getString(R.string.hostname); // it's a normal http 

        StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        Toast.makeText(getApplicationContext(), "Location sent", Toast.LENGTH_SHORT).show();
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                        String errorMessage = "Err - data:"+error.getMessage();
                        Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_SHORT).show();
                }
              })
                    {
                        @Override
                        protected Map<String,String> getParams(){
                            Map<String,String> params = new HashMap<String, String>();
                            params.put(KEY_USERID,pref.getUserId());
                            params.put(KEY_LAT,String.valueOf(location.getLatitude()));
                            params.put(KEY_LNG,String.valueOf(location.getLongitude()));
                            return params;
                        }

                    };
        queue.add(stringRequest);
    }
Compel answered 19/12, 2015 at 5:2 Comment(7)
Which error you get? share your error details....Hadleigh
not able to get error, device is not connected to android studio.(it's a client device), Any idea to get a log from that device without installing android studio ?Compel
yes you can use 'crease report' or 'instabug' in your code. it's very helpful to you without installing android studio that report send directly to your mail id.Hadleigh
@RikzPatel i tried to use acra, but my app is not crashing, it simply not able to connect to network, What else i can do ?Compel
Have you verified that it's not your client's device that is causing the problems?Lorenz
yes i've verified it, post request is working from his mobile browser, and same error is coming from other devicesCompel
so i suggest one thing you used 'Ok Http' rather than volley...Hadleigh
C
0

Actually i saw that the one of the param UserId was having the Null value, That was creating the problem

Compel answered 21/12, 2015 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.