How to make an alert when mobile data is not available?

Hello.

Is there a way to make a short message on the watch when I turn off the connection (mobile data)?

I'm using OWM data, currently I'm using

if (!System.getDeviceSettings().phoneConnected) , but this only solves the problem with BLE.

I still need to solve

var Settings = System.getDeviceSettings();

if (Settings has : connectionAvailable) {.

Or if there is a better way, for example Communications.makeWebRequest?

Then please give an example of how to solve this problem.

Thank you

  • I just wanted to be notified when the connection (mobile data on the watch) drops.

    To be clear, you mean the LTE data connection on an LTE watch right?

    To be absolutely clear, connectionAvailable refers to *any* connection channel (bluetooth/Connect, LTE or wi-fi). It should be true if *any* of those connections is available, and false if *all* of those connections are unavailable.

    Do you need to specifically check for loss of LTE?

    The device in your screenshot doesn't look like a 945LTE or Vivoactive 3 Music LTE. It looks like a Fenix?

  • I figured that out, but it still doesn't work for me and the error message keeps appearing and it interferes with the weather area.

    By error message, I assume you mean *your* error message: "connect to garmin app".

    If your code does not show the error message but mine does, I think that means:

    - "settings has :connectionAvailable" is false for your device (meaning you have an old device - almost certainly not a device that supports LTE - i.e. "mobile data on watch")

    - phoneConnected is also false for your device

    Is your phone connected via bluetooth and is Garmin Connect open on your phone?

    What device are you testing on?

  • yes, in short, when I turn off (button) mobile data on my phone, the data connection with GCM is also interrupted and if the weather is updated and there is no access to data packets, for example, I see an icon.

  • Which watch do you have?  With many there is a system setting where the FW will alert you if the phone connection drops. 

    When I do a makeWebReuest, I don't check the connection status, knowing I'll get the -104 if that's a problem.  It's worked for me for many years.

  • So are we to understand that by "(mobile data)" and "(mobile data on the watch)" you never meant LTE on the Garmin device, but you only meant internet connection via phone / Garmin Connect (watch > BLE > phone > Garmin Connect > internet)?

    If that's the case, phoneConnected should do everything you want. phoneConnected doesn't really mean that the phone is connected, it means that the phone is connected and Connect is open.

    Again, if you had made some details clear in your OP (what device you are using, what exact situation you are testing, what exactly you are trying to accomplish), it would make it so much easier to answer your questions.

  • yes, in short, when I turn off (button) mobile data on my phone, the data connection with GCM is also interrupted and if the weather is updated and there is no access to data packets, for example, I see an icon.

    It's really simple.

    If phoneConnected = true, don't display error message or error icon

    If phoneConnected = false, display error message or error icon

    (if connectionAvailable is present, use that instead of phoneConnected)

    I don't understand why it's a problem to see the error message "connect to garmin app" if you are in fact not connected to the Garmin Connect app, given that it's your choice to have such an error message.

    Again that is why it might be better to just have an icon (like phone with slash through it) or display a blank space / "--".

  • Well, it's strange because when I disconnect and turn off Bluetooth on my phone, the weather error message appears, but when I turn off mobile data on my phone and the weather is updated, the error message does not appear.

  • yes, even an empty space, but display it whenever the data flow (4G) is interrupted.

  • Well, it's strange because when I disconnect and turn off Bluetooth on my phone, the weather error message appears, but when I turn off mobile data on my phone and the weather is updated, the error message does not appear.

    Oh I see. Thank you for finally explaining: "mobile data on my phone"

    You previously said: "I just wanted to be notified when the connection (mobile data on the watch) drops."

    And from the OP I assumed you meant mobile data on watch, too. Which is why I asked about LTE Garmin models.

    Simple explanation: Connect IQ apps cannot detect whether your phone has an internet connection (mobile data or wi-fi).

    phoneConnected = watch is connected to phone via Bluetooth and Connect is open. Nothing to do with internet access on phone.

    connectionAvailable = same as phoneConnected, but also checks whether watch is connected via LTE (only 2 models have LTE) or Wi-Fi (many models have wi-fi, but it won't be used for CIQ internet requests in most cases)

  • yes, even an empty space, but display it whenever the data flow (4G) is interrupted.

    You cannot do so via DeviceSettings.phoneConnected or connectionAvailable. They have no knowledge of whether your phone has internet access.

    Now that we've established that, the solution is to use the response code from makeWebRequest after all.

    If the error code is not 200, then you can display a blank space / error message / error icon.

    You can do a test where your app displays the numerical code (e.g. 200) on the watchface. Turn off the data on your phone, but keep the bluetooth connection with watch and leave Connect open. Wait 5 minutes (or whatever) for makeWebRequest to go out.

    See what code is returned. Maybe it will BLE_HOST_TIMEOUT or BLE_UNKNOWN_SEND_ERROR or UNKNOWN_ERROR.

    Now you know what code will be returned when there's no data on your phone, and you can write your code to handle that case specially, if you want.