How to start a companion app from the watch?

Former Member
Former Member
Hello,

I'm developing a watch app that gets its data from a companion app running on an Android device. My question is: how do I start the companion app, once the watch app is started? Is there a way to make such a request?

I read that the companion app should be made to be a service if it is to provide background data, but how is that service started? Is the Garmin Connect app taking care of this?

Thanks!
  • Former Member
    Former Member over 9 years ago
    No answers? Why is that? What is the correct way to work with companion apps?
  • No answers? Why is that? What is the correct way to work with companion apps?


    Wish I could help. Unfortunately I suspect there are not many developers around here coding companion apps. Lets hope someone answers.
  • Former Member
    Former Member over 9 years ago
    Wish I could help. Unfortunately I suspect there are not many developers around here coding companion apps. Lets hope someone answers.


    Well, if that is so, I expect Garmin staff to properly explain how are companion apps intended to be worked with :-)
  • Former Member
    Former Member over 9 years ago
    Still no answer?
  • Former Member
    Former Member over 9 years ago
    I'm developing a watch app that gets its data from a companion app running on an Android device. My question is: how do I start the companion app, once the watch app is started? Is there a way to make such a request?


    There is no way to trigger a companion app to start from the watch using the partner SDK.

    I read that the companion app should be made to be a service if it is to provide background data, but how is that service started? Is the Garmin Connect app taking care of this?


    We recommend using a service for any sort of continous background communication with a Connect IQ app so you don't bog down the UI of a partner app. In regards to starting and using a service I would refer you to the Android documentation and this tutorial.

    My recommendation would be to register a broadcast receiver which gets notified when a Bluetooth state change occurs. You can then start your service if there are any connected devices and stop your service if there are no longer any devices connected.
  • Former Member
    Former Member over 9 years ago
    There is no way to trigger a companion app to start from the watch using the partner SDK.



    We recommend using a service for any sort of continous background communication with a Connect IQ app so you don't bog down the UI of a partner app. In regards to starting and using a service I would refer you to the Android documentation and this tutorial.

    My recommendation would be to register a broadcast receiver which gets notified when a Bluetooth state change occurs. You can then start your service if there are any connected devices and stop your service if there are no longer any devices connected.


    Hi Ken,

    thanks a lot for the answer. In the meantime, I found my way through this issue, by creating a service.

    Now, I have another question: how do I start a watchapp from my companion app on the phone? The Garmin apps have a way to do that, that's how notifications are transmitted, or incoming calls, but how should third-party apps do that?
  • Now, I have another question: how do I start a watchapp from my companion app on the phone? The Garmin apps have a way to do that, that's how notifications are transmitted, or incoming calls, but how should third-party apps do that?


    You're a bit "apples and oranges" here as the native widgets like notifications need GCM but that's it, and without GCM running on the mobile, the watch itself won't even connect. Also, since they are in the FW, things like notifcations are "always there" and in effect, "running".

    For CIQ apps/widgets, they are only running when you can see them on the screen. They do not run in the background. They are only "there" when you as a user run them.
  • Former Member
    Former Member over 9 years ago
    You're a bit "apples and oranges" here as the native widgets like notifications need GCM but that's it, and without GCM running on the mobile, the watch itself won't even connect. Also, since they are in the FW, things like notifcations are "always there" and in effect, "running".

    For CIQ apps/widgets, they are only running when you can see them on the screen. They do not run in the background. They are only "there" when you as a user run them.


    Hi Jim, thanks for the reply. I didn't quite get the apples and oranges part, but let me elaborate a bit.

    The docs mention the possibility of communicating with a companion app running on the phone, but there is no description, nor an example, of how the two apps should initiate that communication. For example, you say that the CIQ apps run only when a user runs them, and that's very obvious. Now, how should the companion app on the phone know when to start running in order to establish the communication? Garmin left no way of providing this info, so the only way to go is to have the companion app run always, and the most logical way to implement that is as a service running in the background. Not at all an elegant solution, as every app that may be used only a few seconds per day, needs to be using the phone resources all the time. But at least it is a kind of solution.

    For the other way around: I might have a companion app that needs to initiate the communication with the watch app. That is not possible, obviously. That is hindering many usage scenarios, because the usage of notifications just does not always provide what's needed.

    Now, the GCM exists on the phone, and it communicates with the watch. Why not use it to transmit messages such as "start app", or "stop app" from and to the watch?
  • Former Member
    Former Member over 9 years ago
    There are not messages available on either end which will start an app on the other end. Without knowing what exactly you're trying to accomplish with the app/partner app I think you've got two options.

    The first is taking a manual approach of prompting the user to start the app (could be done from either end). You would need to define a "marco polo" style message and the "marco" message would continue to run every few seconds until the other app responds. While it's waiting for a "polo" response you could display a message to the user that they need to check/run the other app. When the start the other app it would hear the "marco" and respond with "polo" at which point you know two way communication has been established.

    The second approach would be running a service continuously on the phone so it would be ready to go when the watch app needs it. As you mentioned that would require the service to be running all the time and if your use case only requires two way communication every once and a while maybe it's not the best solution. You could make this a bit more intelligent by having the service only run when a BLE device is connected (which I mentioned above) but there's still the possibility it's running in the background when you don't need it.

    If you're afraid of the drawbacks of either of those you could design the system so you can configure which approach is used within the companion app. This would let the user decide if they prefer to have the service running without having to manually open the app or if they prefer manually opening the app in order to save the processing power/battery of the background service always running.
  • Former Member
    Former Member over 9 years ago
    Hello Ken,

    thanks for the detailed reply. I currently have 2 CIQ apps that have Android companion app counterparts, one is for speed dialing, and other is the call and sms log (and as of today, they are both published in the store). The companion apps are running as services in the background, nothing else makes sense, since the point of having those apps is to initiate phone calls from the watch, and spare oneself from taking the phone out. It would have been more elegant if there were a possibility to start the companion app only when the watch app is started.

    Where I stumbled upon a limitation: I wanted to make a watch app that displays sms messages, i.e. it starts when a new message arrives. The companion app can register itself as a broadcast receiver, but there is no way for it to start it's watch counterpart.