Reputation: 11
I am unable to get any response from the URL I am hitting using the Volley library, please can you help me out ?
I am getting this on my emulator : "com.android.volley.NoConnectionError:java.io.IOexception:content length promised 45 bytes, but received 0 ."
I have pasted the code below:
String url = "http://ipchicken.com"
JsonObjectRequest jsObjRequest = new JsonObjectRequest(
Request.Method.POST, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// TODO Auto-generated method stub
sampletext.setText("Response => " + response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
sampletext.setText( error.toString());
}
});
queue.add(jsObjRequest);
Upvotes: 1
Views: 2760
Reputation: 1817
Why you use POST method? If you need exactly POST, where are params?
I think, you should use GET method and parse request to find your name address or something else.
Upvotes: 0
Reputation: 69
In addition to what has been answered above: The url does not return any JSONObject, hence why you do not see any response [Your request is that of a JSONObject, meaning Volley expects JSONObject back as a response]. Maybe use the StringRequest instead.
Upvotes: 0
Reputation: 33
If you constructed your RequestQueue
by hand, instead of calling Volley.newRequestQueue
, you need to call .start()
on it. Otherwise it looks fine.
Thanks
Upvotes: 3
Reputation: 699
You most likely need to include the INTERNET uses-permission in your manifest.
<uses-permission android:name="android.permission.INTERNET" />
Upvotes: -1