Android application connect to local area Wamp Server

I need to connect my app to the wamp server located in my machine within my LAN, in order to test an api I am currently developing. While using the phone internet browser, I can access the ip address for api viewing, but using something similar to the following code does not work.

        URL url = new URL("192.168.1.1/api/v1/home");
        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");

Please give some suggestions in order to be able to test this.

Upvotes: 0

Views: 47

Answers (2)

Mushirih
Mushirih

Reputation: 451

Try adding http before the link

URL url = new URL("http://192.168.1.1/api/v1/home");
        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");

Upvotes: 1

fsnasser
fsnasser

Reputation: 203

Are you using the emulator? If so change your IP to this: http://10.0.2.2

Upvotes: 0

Related Questions