Search code examples
androidandroid-emulatorandroid-volleywear-os

Wear os App cant make Volley request outside of Emulator


I'm working on an Android Wear OS app that communicates with a local Web-Api to GET and POST data. When I run my app from an Emulator, everything works as expected. But after installing the App on my Watch, my Volley-Requests stop working.

In my AndroidManifest.xml I added these Permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Volley GET-Request:

    public void getRequest(String path, final VolleyCallback callback) {
    String URL = mainURL + path;
    StringRequest stringRequest = new StringRequest(
            Request.Method.GET,
            URL,
            callback::onSuccess,
            callback::onError
    ) {
        @Override
        public Map<String, String> getHeaders() {
            return createHeader();
        }

        @Override
        protected Response<String> parseNetworkResponse(NetworkResponse response) {
            callback.statusCode(response.statusCode);
            return super.parseNetworkResponse(response);
        }
    };
    requestQueue.add(stringRequest);
}

(I create my request Queue in the Constructor)

In Wireshark, I was able to see that my Watch isn't sending any HTTP-Requests.

Do I need any additional Setup in order to send these requests from my Watch?


Solution

  • The problem occurred because the Network I was on Blocked my Traffic with a Firewall