Start an Android service from watch

Hi everyone,

I'm sure I just overlooked something, but I can't find any clues on how to intercept a message from watch as an intent.
Other watches such as Android Wear or Pebble both have an app intercepting any messages and distributing the corresponding intents.

E.g. on Pebble, all messages from watch go to the Pebble app. When the Pebble application receives a message from a watch application, it broadcasts an intent with action “com.getpebble.action.app.RECEIVE“, and ‘extra’ data containing the message content.

I couldn't find anything like that in the CIQ SDK, although there is also a Garmin Connect Mobile app that could theoretically do this.

What I want to do is to start my Android service (via a Broadcast intent receiver) whenever my CIQ app sends a message to the phone.

Is there a way to do that?
  • We have figured out how to intercept the messages from the watch without having a service running all the time.
    We've decompiled the connectiq.jar to see that the SDK's receiver is expecting a following intent
    public static final String INCOMING_MESSAGE = "com.garmin.android.connectiq.INCOMING_MESSAGE";

    with following extras
    public static final String EXTRA_APPLICATION_ID = "com.garmin.android.connectiq.EXTRA_APPLICATION_ID";
    public static final String EXTRA_PAYLOAD = "com.garmin.android.connectiq.EXTRA_PAYLOAD";
    public static final String EXTRA_REMOTE_APPLICATION = "com.garmin.android.connectiq.EXTRA_REMOTE_APPLICATION";
    public static final String EXTRA_REMOTE_DEVICE = "com.garmin.android.connectiq.EXTRA_REMOTE_DEVICE";


    So you can just register a receiver for INCOMING_MESSAGE in your manifest, and in that receiver check manually for your application's ID, if it's correct, then start your service and handle the payload.
    Or you can handle the payload right away in the receiver.

    If anyone wants a code sample, let me know.
  • Any chance of figuring out what intent you need to send to the connect IQ app to open an app on the watch? That is the other pebble app I would love to reproduce.

    Please share your example code of how the messages within also if you can. I'd like to recreate the Tasker profile without Autonotification.
  • Francisco road

    Didn't try this yet, but there is also a
    public static final String OPEN_APPLICATION = "com.garmin.android.connectiq.OPEN_APPLICATION";

    intent which I couldn't trigger from the watch, so maybe this intent is for opening the app on watch....but seems to me that this functionality is not implemented yet....but by all means try and post back!
  • Coleman just turned my attention to the fact that in the CIQ Mobile SDK v1.3, there is a new feature to open an app on the watch from phone (sort of).

    Opening an App on the Device

    You may wish to prompt the user to open a Connect IQ application on their device. To do this you can use the openApplication API. A response from the device will be returned to your IQOpenApplicationListener.

    connectIQ.openApplication(device, app, new IQOpenApplicationListener() {

    @Override
    public void onOpenApplicationResponse(IQDevice device, IQApp app, IQOpenApplicationStatus status) {
    // Handle the response here
    }

    });
    Possible Open Application Statuses

    PROMPT_SHOWN_ON_DEVICE
    PROMPT_NOT_SHOWN_ON_DEVICE
    APP_IS_NOT_INSTALLED
    APP_IS_ALREADY_RUNNING
    UNKNOWN_FAILURE
  • Please share your example code of how the messages within also if you can. I'd like to recreate the Tasker profile without Autonotification.


    I don't actually parse the messages. Whenever a message comes from the watch, a com.garmin.android.connectiq.INCOMING_MESSAGE is broadcast.
    I listen to this broadcast and check whether the com.garmin.android.connectiq.EXTRA_APPLICATION_ID equals to my watchapp's ID. And if yes, I initialize the SDK and establish normal connection.

    My receiver looks like
    public class MyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
    if ((ConnectIQ.INCOMING_MESSAGE.equals(intent.getAction()) && intent.hasExtra(ConnectIQ.EXTRA_APPLICATION_ID) && MyService.IQ_APP_ID.equals(intent.getStringExtra(ConnectIQ.EXTRA_APPLICATION_ID)) {
    context.startService(new Intent(context, MyService.class));
    }

    where IQ_APP_ID is a final where I have stored the watchapp's ID.

    You could also decode the message body manually. The actual message is in com.garmin.android.connectiq.EXTRA_PAYLOAD extra, and seems to be encoded as a bytearray (looks like [B@405217f8 ), so you could decode it using String s = new String(message);