8

how can I execute HTTP requests or open a socket on Android Wear? I used to think that's impossible but the Web Browser for Android Wear app says the folloing:

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

I tested it and that app CAN connect the internet when the paired phone is powered 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). So I'm doing something different then that app is doing and I'd like to understand what that is.

Context: I'm working on proof-of-concept and just want to be able to execute HTTP requests and open sockets. I'd love to know if there's any way to do that. Even if it includes rooting the watch and doing some adb magic.

To clarify: I know about the Data Layer API and i'd still like to be able to just do HTTP requests and open sockets.

Community
  • 1
  • 1
JustinAngel
  • 16,082
  • 3
  • 44
  • 73
  • The stack you referred to seems to indicate that the other side has refused the connection and doesn't point to any issue on the wear side. In your case, create a clean stack that shows the issue is on the wear side and show us the stack and your code. Also make sure your war device is indeed on the WiFi network when you try it. – Ali Naddaf Jul 17 '15 at 16:35

1 Answers1

5

If your watch has Wifi and it is set up correctly, then you can make network calls on your watch when your watch is disconnected from the phone; when you connect to your phone via BT, wifi will be disabled. While it is enabled, you should be able to treat that as a usual network connectivity and make network calls. But keep in mind that if you write an app that relies on this, your app will fail to work when it gets connected to a phone so you need to handle that case and provide an alternative for your app to get the same data (i.e. using the phone's connectivity).

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • Can somebody tell me why google has horrible documentation for Wear OS dev ? It assumes all wear OS watches can make network calls. Mine is LG G Watch and it can't connect to network – SimpleGuy Jun 12 '21 at 01:59