I've developed an wear os 2.0+ app which communicates with an HTTP API. I'm using Volley to connect to this API, but it only seems to work whenever I've switched bluetooth off. Any requests I make with bluetooth simply timeout. The other end usually respond within miliseconds and returns not more than a few kilobytes.
The documentation states the following regarding networks access:
Wear OS apps can make network requests. When a watch has a Bluetooth connection to a phone, the watch's network traffic generally is proxied through the phone. But when a phone is unavailable, Wi-Fi and cellular networks are used, depending on the hardware. The Wear platform handles transitions between networks.
So from my understanding Android should take care of making sure my requests make it to the other end, either with bluetooth (proxied through phone) or wifi.
The actual code which makes the HTTP request with volley:
public <T> CompletableFuture<T> send(String url, Class<T> type) {
CompletableFuture<T> requestCompletableFuture = new CompletableFuture<>();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
response -> {
T data = serializer.fromJson(response.toString(), type);
requestCompletableFuture.complete(data);
}, (ex) -> {
requestCompletableFuture.completeExceptionally(ex);
});
request.setRetryPolicy(new DefaultRetryPolicy(15000,
0,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
requestQueue.add(request);
return requestCompletableFuture;
}
Android does provide a ConnectivityManager which gives me the ability to request a WIFI network. But creating a high bandwith network which I don't need sounds a bit unnecessary and battery draining what I am trying to prevent.