からレスポンスを受信していない、私のPHPサーバでは私のAndroidのクライアントに非常に単純な文字列をエコーされます。AndroidはデバッグのためにPHPサーバー
<?php echo "I REALLY LIKE PIE" ?>
は私のAndroidのクライアントは、このような文字列を受信するために、次のコードを持っています
URL url = new URL("http://192.168.0.107/index.php");
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setReadTimeout(10000);
urlConnection.setConnectTimeout(15000);
urlConnection.setRequestMethod("POST");
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.connect();
int HTTPResult = urlConnection.getResponseCode();
if (HTTPResult == HttpURLConnection.HTTP_OK) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String output = "";
while ((output = bufferedReader.readLine()) != null) {
returnedString.append(output);
}
bufferedReader.close();
}
urlConnection.disconnect();
しかし、変数 "output"はnullであるため、返される文字列もnullです。なぜ私は応答がないのですか?
http://192.168.0.107/index.phpローカルIPおよびおそらくあなたのAndroidデバイスとのアクセスすることはできません。 –
はHTTPResult? –
192.168.0.107の値が、それは、ネットワークのいただきました?接続成功ですIPアドレスまたはあなたのプロジェクトがセットアップされているシステムのIPアドレス? あなたのシステムのIPアドレスなら、それは直接動作しません。 ネットワークIPアドレスでプロジェクトがサーバーに設定されている場合は、デバイスをネットワーク(Wi-Fi経由)に接続できます。あなたが共有しているプロジェクトリソースにアクセスすることができます。 –