0

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?

go3d
  • 443
  • 3
  • 11

1 Answers1

0

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
);
Yong
  • 1,529
  • 12
  • 21
  • Thanks. But in order to not drain the battery, is there no way to get a connection via Bluetooth? – go3d Apr 12 '23 at 17:58
  • WearOS create a proxy through bluetooth, and you can request data from the Internet when the proxy is connected. It's no need to force it through bluetooth. If you don't request wifi, the network will go through the proxy. – Yong Apr 13 '23 at 11:09
  • Yes, that's what I am expecting. But the problem seems to be that the connection is lost when in ambient mode – go3d Apr 16 '23 at 00:56