私は自分のphpファイルが機能することを知っています.localhostから呼び出すことができ、応答を得ることができます. また、AVD でブラウザーから URL を呼び出すと応答が返されるため、AVD から呼び出すための正しい IP アドレスがあることもわかっています。したがって、問題は私の asynctask 関数にあります。
asynctask クラスのコードは次のとおりです。
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();
}
親クラスからこのクラスを呼び出し、onpostexecute() からの文字列を、親クラスの文字列である文字列 resp に入れています。応答は常に null です。