Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPS connection on wi-fi enabled Android Wear without phone tethering

I can't find any documentation on Android Wear that shows how to create an app that leverages the fact that some watches (like my Samsung Galaxy Gear) can now connect directly to the internet via wi-fi when the phone is not around.

I have a few apps that generate https requests to access a REST service and I would like to know if these can be directly called from a Wear app connected to wi-fi (no phone).

Similar questions don't seem to answer this:

Direct internet connection on Android Wear?

https://stackoverflow.com/questions/26062487/android-wi-fi-direct-persistent-connection

Android: Establish "Wi-Fi Direct" connection with networked devices

My tests on a Wear emulator tethered to an internet enabled Phone emulator show:

java.net.UnknownHostException: Unable to resolve host "api.xxx.com": No address associated with hostname

But of course there's no direct wi-fi connection on the watch emulator so my next step is to try on a real watch and phone.

My suspicion is that Android Wear's data API handles this transparently so direct http requests seem impossible.

Best, thanks in advance for your help.

like image 844
German Avatar asked Oct 31 '22 02:10

German


2 Answers

Even if Android 5.1.1 support Wi-Fi Feature. Android Wear on Wi-Fi: Using a smartwatch without a phone nearby

You should stick to the Data Layer API, you cannot send http request directly from watch. Fetch internet data from the phone, then transfer it to watch with Data Layer API.

You can see this Does Android Wear support directly access the Internet?

And this document Always-on and Wi-Fi with the latest Android Wear update

like image 170
Hsiao yen Avatar answered Nov 15 '22 04:11

Hsiao yen


From the last update its possible to make http requests over wifi using android wear. You can even connect a bluetooth headphone to it to use with some streaming app.

While on wifi, if your mobile phone is connected to the internet too (dont need to be the same wifi, can be even 3g) it will act the same way it would when bluetooth connected yo our phone, but with its own internet access.

This dont mean apps will change their behavior, because most of them are coded to make the requests from your phone, but if you have an app that make direct networks requests, it will send them from your watch without advising or needing your phone.


How to do networks requests on android wear

Just use the same network requests libraries you would use on a normal Android mobile application, like volley, retrofit, okhttp. The code is exactally the same, and by the way, any Android Mobile library works with Android Wear too.

like image 28
Renato Probst Avatar answered Nov 15 '22 05:11

Renato Probst