I know my php file works, I can call it from localhost and I get the response.
I also know I have the correct ip address for calling it from the AVD because when I call the url from the browser in the AVD I get a response.
So the problem is in my asynctask function.
Here’s my code from the asynctask class.
protected String doInBackground(String... args) {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
try {
response = httpclient.execute(new HttpGet(url));
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String str) {
// updating UI from Background Thread
resp=str;
returned();
}
I’m calling this class from the parent class and putting the string from onpostexecute() to string resp, which is a string in the parent class. The response is always null.
Well, you ARE returning
null, so your code is working as written.Maybe instead of
return nullindoInBackground(), you want to return part of the http response?