How can I access my local REST api from my android device?
<p>I have a spring REST api running locally on my computer.  I would like to consume this api for android development. </p>

<p>Here is my get request:</p>

<pre><code>public static String sendGet(final String url) {
        StringBuilder result = new StringBuilder();
        HttpURLConnection urlConnection = null;
        try {
            String apiUrl = getAbsoluteUrl(url); // concatenate uri with base url eg: localhost:8080/ + uri
            URL requestUrl = new URL(apiUrl);
            urlConnection = (HttpURLConnection) requestUrl.openConnection();
            urlConnection.connect(); // no connection is made
            InputStream in = new BufferedInputStream(urlConnection.getInputStream());
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            String line;
            while ((line = reader.readLine()) != null) {
                result.append(line);
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            urlConnection.disconnect();
        }
        return result.toString();
    }
</code></pre>

<p>I can access my api via my device's browser. However, when I use this same url within the built apk to make the request, no connection is made. </p>

<p>My manifest includes:</p>

<pre><code>&lt;uses-permission android:name="android.permission.INTERNET"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
</code></pre>

<p>Side notes:</p>

<p>I am connecting my device to my laptop running the rest api via usb.
I am using the WLAN IPv4 address found by calling ipconfig.</p>

<p>Any tips in the right direction would be much appreciated - thanks!</p>

<p>Edit to include chrome browser (on android device) output from local REST api running on my laptop (A GET request to return default guest user information):
<a href="https://i.stack.imgur.com/rTQ5I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rTQ5I.png" alt="enter image description here"></a></p>