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.
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
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.
Related
I am developing a device that needs to communicate securely to an Android app via Bluetooth. I need that only a predefined phone to be able to communicate with my device for security reason. And I also need to assure that this is not an intruder device that is trying to communicate falsified data to the app.
Looking at Bluetooth specs, I had the impression the only way to do that is with out of band (OOB) authentication with a pre-provisioning temporary key (TK). This looked very promising but after trying to find how to use OOB on an Android app, it seems like it is not supported.
Is it still possible to use OOB authentification on Android ?
If no, is there another alternative to solve my issue ?
This is doable but it depends on the BLE peripheral that you are developing and the features that it supports. Namely, your device needs to support Whitelisting and bonding. This is how it should work.
Upon first connection to the BLE device, the BLE device should accept the connection regardless.
Once the connection is made, the central device (Android phone) needs to initiate bonding. This doesn't need to be Out of Band (OOB) bonding, and the standard Just Works bonding should do.
Once bonding is succesful, the BLE peripheral should add the Android device's IRK to the list of whitelisted devices.
From this point onwards, the BLE peripheral will activate the whitelist, and therefore only devices in the whitelist will be able to connect to your BLE peripheral, and in your case it will be the Android phone that you used to make the very first connection.
It is not straight-forward and requires an initial secure-less connection with the target phone, but if that is not an issue then this should work.
You can find more information about this in the links below:-
Set and activate whitelist with Android phone
Android BLE server - allow only previously connected device to connect
Whitelisting with resolvable random addresses
I am making a local web app. Users will connect through WiFi and all DNS requests result IP of my server. Windows PCs and phones check http://www.msftncsi.com/ncsi.txt for check internet connectivity. So I made a simple text file with that name and they think it is OK.
I have problem with Android and iOS smartphones. Specially iOS, It disconnect WiFi if user ignores its alert.
I think android phones connect to mtalk.google.com:5228 to check notifications and other things.
How can i fool them?
"Basically, it’s the Network connectivity status indicator (NCSI) service that does the trick..."
You can see at: http://www.nextofwindows.com/how-windows-7-knows-my-network-connection-status
I have a Bluetooth device through which user can take photos. After taking the photos Bluetooth device hosts all the images on its own HTTP server (10.0.0.1), so that other devices can connect to server using Bluetooth and access photos from server using REST APIs which are exposed by server.
Steps to connect to Bluetooth device (Server)
Go to Setting, enable Bluetooth
Select Bluetooth device
Bluetooth device setting ("Paired Bluetooth device")
Select check box for Internet access.
Through this i am able to access Bluetooth server but my WiFi automatically gets disabled and I am not able to access internet.
If i uncheck "Internet access" check box in "Paired Bluetooth device setting" then I am able to connect to WiFi for internet access.
Is it possible to have both WiFi internet as well as Bluetooth internet at the same time? So that my app can connect to Bluetooth device to get the data (images) using REST APIs and post to remote server using WiFi.
I am using Nexus 7 tab for development which is running on Android 4.4.4.
1. ...so that other devices can connect to server using Bluetooth and access photos from server using REST APIs which are exposed by server
If the photos are on the server, devices can connect to it using wifi/internet also..right? To access the APIs and get the photos..
Why do you want other devices to connect to server using bluetooth to access photos from server using REST APIs
2. Is it possible to have both WiFi internet as well as Bluetooth internet at the same time?
Leave aside Bluetooth internet, there have been some issues related to Bluetooth and Wifi, even more with Bluetooth Low Energy and Wifi, many have been device specific.
Regarding what you are facing, there are issues on Android Open Source Project - Issue Tracker and other blogs also;
Issue 39995
Issue 41631
Nexus 5, Nexus 4 and Nexus 7 (2013) Android 4.4 Bluetooth Issues
[Although i haven't faced that issue in Nexus 5]
I have seen the same in MotoG also, turning on Bluetooth weakens the Wifi functionality.
In your case, considering nothing can be done with the device and its hardware,
you can check with the connections whether it happens intermittently, try to connect or send the request to server a couple of times.
3. ...app can connect to Bluetooth device to get the data (images) using REST APIs
If it can "connect" to the Bluetooth device, i suggest you try and get the images on the established connection rather than REST APIs. Simultaneous internet access through two different sources doesn't happen, even with the 3G and wifi :)
Just out of curiosity, when you are connected to the Bluetooth device, why do you want to add the necessity of internet to get the data?
Another approach, gets ugly but would work: Can you get the data that you need and ask the user to switch off the bluetooth so you can send the data..which you might need only on certain devices, if you separately get the data from the established bluetooth connection only
Is it possible to connect two android phones (rooted) with wifi programatically and exchange data?
I know it is possible to do tethering using wifi-android-tether. But i need to establish the connection, and exchange the data, all through my android application. User intervention like switching on the android tether app manually is not allowed.
SO basically its like, if i run my app on two droid phones, they should do the following,
Detect that they have wifi.
DEtect that the other phone has its wifi on.
Establish a connection ( similar to a PAN in bluetooth ).
Exchange some data.
Use WiFi Direct. The sample codes in the SDK package will do for testing Peer-Peer connectivity.
I'm trying to develop an Android application which have to be able to transfer data/message between two Android mobiles, as a client server connection using their own Wifi, which having no network or routers nearby. I just tried using Tcp program to do this but it fails, its not connecting, I'm getting ConnectException and connection refused.
[Edited] Is it possible to achieve this using Android Portable Hotspot integrated with application? Is there any tutorial regarding this approach?
Any Ideas, how to do this?
Thanks.
You need to get the two devices networked to each other before you can worry about tcp usage of that network connection.
If one device is willing to perform access-point like functionality as part of a portable hotspot, and you select that as a wirelss network on the other, you may achieve a network connection between the two that can be used for custom traffic. Though there are ways the hotspot could be implemented where that would not work. Also of concern, the "client" device will now be sending all of its network traffic through the hotspot device, including not just foreground apps but anything it decides to do in the background.