我從android調用php url來接收一些字符串值。
我的Android代碼如下:php返回null http響應android
private static final String BASE_URL="http://10.10.2.26/demo";
public static HttpResponse executeUrl(String action,String[] parameters) {
try {
HttpClient client = new DefaultHttpClient();
URI website = new URI(BASE_URL+"/"+action);
System.out.println("serverurl="+website);
HttpGet request = new HttpGet();
request.setURI(website);
System.out.println("5");
HttpResponse response = client.execute(request);
System.out.println("no error in execute URL");
return response;
} catch (Exception e) {
System.out.println("In error of execute URL"+e.getLocalizedMessage());
}
return null;
}
以下是我的PHP代碼:
<?php
echo "kunal";
?>
執行後,我收到空到Android。
請發佈您的PHP代碼 – Manitoba
我添加了代碼,但沒有顯示。我的代碼是<?php echo「kunal」; ?> –
Btw你的IP是本地地址。 – Manitoba