Not Getting Response Response = Httpclient.execute(request);
public class HTTPPoster { public static HttpResponse doPost(String url, JSONObject c) throws ClientProtocolException, IOException { HttpClient httpclient = new De
Solution 1:
You should call the method asynchronously. Then it will work with the same code. Add these two lines of code to your project
StrictMode.ThreadPolicypolicy=newStrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
and make minimum sdk version to 9
Solution 2:
You can check that if you are getting response from server or not by using following code :
HttpResponseresponse= httpClient1.execute(request);
Log.v("response code", response.getStatusLine()
.getStatusCode() + "");
If you get the value of response code as 200 then you are getting data from server and if the response code value >=300 then you have error at your server side.
Solution 3:
First of all try to change the return type to String
by doing these 2 steps
Change
publicstaticHttpResponsedoPost(String url, JSONObject c) throws ClientProtocolException, IOException
to
publicstaticStringdoPost(String url, JSONObject c) throws ClientProtocolException, IOException
AND
Change
HttpResponse response;
to
String response;
Now check the response string? Is it still null?
Solution 4:
This is a permission issue.
Add this line <uses-permission android:name="android.permission.INTERNET" />
to your manifest file and rebuild.
Post a Comment for "Not Getting Response Response = Httpclient.execute(request);"