Reputation: 463
I am developing a watch face that retrieves some data from the internet and updates an indicator every 3 minutes. But it looks like while the watch (Galaxy Watch4) is in ambient mode, the internet connection is suspended and the indicator can no longer be updated until the user taps the screen and the watch switches back to full on.
However, when I deactivate the WiFi connection on the watch, the data is still retrieved via the Bluetooth connection to the phone. And data retrieval works fine even in ambient mode. Why is this so?
I understand that the WiFi connection requires more power than Bluetooth, so perhaps the system suspends the WiFi connection. But why does it not default to Bluetooth? Is there a way to force the network connection to use Bluetooth always regardless of the WiFi state on the watch?
UPDATE: Is it possible that the better or only solution for this is to have a running companion app (service) on the phone, which regularly sends updated data to the watch via Bluetooth?
Upvotes: 0
Views: 245
Reputation: 1978
The WiFi will automatically turn off in Wear OS. If you want to keep the the WiFi on, your should make a NetworkRequest to turn WiFi on.
ConnectivityManager.NetworkCallback callback = new ConnectivityManager.NetworkCallback() {
public void onAvailable(Network network) {
super.onAvailable(network);
// The Wi-Fi network has been acquired. Bind it to use this network by default.
connectivityManager.bindProcessToNetwork(network);
}
public void onLost(Network network) {
super.onLost(network);
// Called when a network disconnects or otherwise no longer satisfies this request or callback.
}
};
connectivityManager.requestNetwork(
new NetworkRequest.Builder().addTransportType(NetworkCapabilities.TRANSPORT_WIFI).build(),
callback
);
Upvotes: 0