launch a device app from companion android/ios app?

Hello,

I have this cool watch app I am working on.  I would like to develop companion apps for android and ios, which are capable of launching said watch app.  Seems like that would be an easy task.  My one requirement is that I pass it arguments when I launch it, kind of like System.exitTo( new System.Intent("manifest-id://xxxxxxxx-xx-x-x-xxx-xx-xxxx", arguments) );  and "arguments" is my parameters.

Is there an example of how I would do this?  Or simple steps?  I did some searching but all I can find are discussions about how to launch the companion app from the watch, which is not what I am looking for.  
Thank you in advance.
  • (a) My goal is to launch an app with parameters, think launching an intent.  I know it's not directly possible to launch an app via companion android/ios app.  But I'm curious about a small detail.  Please confirm, you're saying that it is not possible to launch a device app, even indirectly through communications between the companion app and Garmin Connect Mobile (GCM)?  i.e., user launches companion app, and the companion app calls a function on GCM, which launches the device app with params.

    (b) Assuming that the above is true, it sounds like the only way to pass parameters to an app, outside of having the user edit the settings themselves, is through the monkey communications library.  That is, using communication-messages, of which the listener must be initiated by the app itself (I am not fully familiar with the communications functionality, but this is what I got from a quick read through of the topic)

    (c) Therefore, please confirm this last part:  the sequence of the operation would be as follows  -1- User launches device app which initiates a listener function kind of like the sensor or onPosition, -2- User launches companion app, which sends messages after initiating communication connection with watch app *through* GCM.

    (d) One final question, and please excuse me for not knowing this part.  Does the monkey communications library allow for companion apps to send and receive messages from the app, or is it one way only?

    (F) finally, please confirm, there is no way to update app settings from a companion app, even indirectly through function calls through GCM?

    Thank you

  • There indeed is a possibility to do so. I recommend taking a look at Garmin's mobile SDK, e.g. for android:

    https://developer.garmin.com/connect-iq/core-topics/mobile-sdk-for-android/

    There is an (undocumented?) method connectIQ.openApplication()

    Example code how to launch the CIQ app (android code):

            ConnectIQ connectIQ = ConnectIQ.getInstance();
    connectIQ.initialize(this, true, new ConnectIQ.ConnectIQListener() {
    @Override
    public void onSdkReady() {
    Toast.makeText(MainActivity.this, "ConnectIQ ready", Toast.LENGTH_SHORT).show();

    try {
    List<IQDevice> devices = connectIQ.getConnectedDevices();
    if (devices != null) {
    for (final IQDevice device : devices) {

    connectIQ.getApplicationInfo(APP_ID, device, new ConnectIQ.IQApplicationInfoListener() {

    @Override
    public void onApplicationInfoReceived(IQApp iqApp) {
    try {
    Toast.makeText(MainActivity.this, "App found", Toast.LENGTH_SHORT).show();
    connectIQ.openApplication(device, iqApp, (iqDevice, iqApp1, iqOpenApplicationStatus) -> Toast.makeText(MainActivity.this, iqOpenApplicationStatus.name(), Toast.LENGTH_SHORT).show());
    } catch (InvalidStateException | ServiceUnavailableException e) {
    e.printStackTrace();
    }
    }

    @Override
    public void onApplicationNotInstalled(String s) {
    Toast.makeText(MainActivity.this, "CIQ App not installed", Toast.LENGTH_SHORT).show();
    }
    });



    }
    }
    } catch (InvalidStateException | ServiceUnavailableException e) {
    e.printStackTrace();
    }
    }

    @Override
    public void onInitializeError(ConnectIQ.IQSdkErrorStatus iqSdkErrorStatus) {
    Toast.makeText(MainActivity.this, "ConnectIQ init failed", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSdkShutDown() {
    Toast.makeText(MainActivity.this, "ConnectIQ shutdown", Toast.LENGTH_SHORT).show();
    }
    });
  • I'd do a simple test app before spending a bunch of time on this.  It could be something planned, but not fully implemented, and might not be smooth even if it is.  What happens if the user is running a native activity or CIQ device app?  Is the user asked if they want to terminate what's already running on the watch, for example

  • For what it's worth, people have been using and talking about  connectIQ.openApplication() for over 6 years. A Garmin employee responded to a bug report about it, and didn't tell the dev not to use it or that it was unstable/unsupported.

    6 years seems like a long time to leave a work-in-progress function in the API without either finalizing it or removing it.

    https://forums.garmin.com/developer/connect-iq/f/discussion/237001/mobile-sdk-openapplication-behaviour-in-ciq-3-2-just-this-once-always-no

    https://forums.garmin.com/developer/connect-iq/f/discussion/4620/vivoactive-hr-crash-on-startup-via-connectiq-openapplication

  • This gives some area to research.  I suppose sending messages could be interpreted by the watch app, and therefore allow me to pass parameters.  So, I am very hopeful after hearing everyone's messages, even though I have not yet programmed for android/ios. I also appreciate the warning about the companion app api not being perfect when it comes to this usage. Maybe the solution lies in messaging.

    Thanks all!

  • I have tested openApplication with iOS and Venu, and it seems to work reliably. I've noticed that if your app is already open, it still prompts the user to open the app (which results in a restart of the app).