爲localhost通過機器人程序與給本地主機地址一樣連接通過Android模擬器與XAMPP服務器
try {
url = "http://10.0.2.2:80/xxx/";
//optionally I tried
//url="http://localhost/xxx/";
//url="http://192.168.1.8/xxx/";
//url="http://127.0.0.1/xxx/";
//above all options are not working for me.
httpclient = new DefaultHttpClient();
request = new HttpGet(url);
response = httpclient.execute(request);
}
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
// Appending result to textview
result.append(line);
}
上述所有網址運行PHP腳本未能連我檢查我的防火牆設置,但它不工作連接。 需要幫助我被困在這個線程中。
你有沒有遇到任何錯誤,請發佈logcat? – 2014-11-03 11:14:08
您確定Web服務器託管在端口80上嗎? – silentw 2014-11-03 11:14:50
無論如何,在這裏你有你需要看的文檔:http://developer.android.com/tools/devices/emulator.html#networkaddresses – silentw 2014-11-03 11:15:40