Since API level 2.2.0
Intents allow a Connect IQ watch-app or widget to launch another Connect IQ watch-app, Connect IQ widget, or native application (e.g. built in activities like Run, Bike, etc.) by calling System.exitTo()
:
Calling exitTo()
will cause a confirmation view to be displayed asking the user whether to exit to the intended app. If the user chooses ‘No’ then the app that called exitTo()
will continue to run. If the user chooses ‘Yes’ then the app will exit and the new app will launch. While the confirmation view is shown, the originating app will continue to run.
In order to exit to another Connect IQ app, a System.Intent
must be created, which contains a target app identifier and any arguments you wish to pass to the target app. The target app identifier must be specified using one of two supported URI schemes:
manifest-id://
followed by a valid UUID from the app’s manifest.xmlstore-id://
followed by a valid app store UUIDArguments are passsed to the target app as a dictionary, which may be empty or null
, and are received by the target app’s AppBase.onStart()
method as a Dictionary
object.
import Toybox.System;
...
var intent = new System.Intent("manifest-id://01234567-89AB-CDEF-0123-456789ABCDEF", {"lat"=>38.856419, "lon"=>-94.801369});
System.exitTo(intent);
Assuming the target app is installed on the device, this example launches the app with manifest ID 01234567-89AB-CDEF-0123-456789ABCDEF
and passes it the "lat"
and "lon"
arguments.
Intent
objects to launch native apps deal exclusively with PersistedContent
objects, such as PersistedContent.Waypoint
, PersistedContent.Routes
, and PersistedContent.Tracks
. Connect IQ handles most of the Intent
functionality for native apps behind the scenes, automatically embedding the appropriate native app identifier in the PersistedContent
object, which is accessible via the toIntent()
method. See the Persisted Content section for more information.
Connect IQ includes three exception types related to intents:
System.UnexpectedAppTypeException
is thrown if your app tries to exit to a Connect IQ app type other than device app or widgetSystem.AppNotInstalledException
is thrown if your app tries to exit to an app that is not installedSystem.PreviousOperationNotCompleteException
is thrown if exitTo()
is called a while a confirmation view from a previous exitTo()
call has not been acknowledged by the user