How to make HTTP requests via Wi-Fi directly with Android Wear?

How can I execute HTTP requests or open a socket on Android Wear? I used to think it was impossible, but the Android Wear web browser says the following:

"[..] works even when your phone is off, if you have a smart watch with Android Wear 5.1 and WiFi." *

I tested it, and this application MAY connect to the Internet when the paired phone is turned off.

Whenever I open a socket or try HTTP requests on Android Wear, I always get a ConnectException saying failed to connect to http://foo.com (similar stack trace here ). Therefore, I am doing something different than this application does, and I would like to understand what it is.

Context: I am working on a proof of concept and just want to be able to perform HTTP requests and open sockets. I would like to know if there is a way to do this. Even if it involves rooting the watch and doing adb magic.

To clarify: I know about the data-level API, and I would still like to just make HTTP requests and open sockets.

+8
android android wear
source share
1 answer

If your watch has Wifi and it is configured correctly, you can make network calls on your watch when your watch is disconnected from the phone; When you connect to the phone via BT, Wi-Fi will be disconnected. Although it is turned on, you should be able to view this as a normal network connection and make network calls. But keep in mind that if you write an application that relies on this, your application will not be able to work when it connects to the phone, so you need to handle this case and provide an alternative for your application to get the same data (i.e. using telephone communications).

+4
source

All Articles