Question: I try to connect MySql.And can use the PostMan get data from 192.168.56.1:8080/BookBankService/rest/api/getall and when I use chorme in genymotion browse 192.168.56.1:8080/ can see the tomcat page. But when I test my code the result return null. And when I use debugger I can see the postRequest url is 192.168.56.1t:8080/BookBankService/rest/api/getall
(Ingore locahost mean 192.168.56.1 here)

```
public static String post(String url, String json) {
    LocalhostURL ="http://192.168.56.1:8080/BookBankService/rest/api"
           String result = "";
    try {
        String strRequest = LocalhostURL + url;
        HttpPost postRequest = new HttpPost(strRequest);
        postRequest.setHeader("Content-type", "application/json");
        postRequest.setHeader("accept", "application/json");
        postRequest.setHeader("accept","text/plain");
        StringEntity s = new StringEntity(json);
        s.setContentEncoding("UTF-8");
        s.setContentType("application/json");
        postRequest.setEntity(s);
        HttpResponse response = httpClient.execute(postRequest);
        result = getResult(response).toString();

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
    return result;
}

```

Answer: 
Android Http request must be executed in AsyncTask or Handler.
If none, then you'll try to get the result before the execute returned a value.

Take a look at a class i created.

[Java : a WebService asking embeded in a AsyncTask](https://stackoverflow.com/questions/22694400/java-a-webservice-asking-embeded-in-a-asynctask)
where do you are testing your code?
If you're testing it in an emulator you have to replace "localhost" with "10.0.0.2" that is the IP address of the host machine.
For further info please read here: <http://developer.android.com/guide/faq/commontasks.html> - section "Referring to localhost from the emulated environment"