Wearable

Remote App Control

A remote application control (app control) is a way of interacting with a remote application installed on a remote host device. The remote app control can be used to invoke or launch a remote application explicitly or implicitly based on the available information, such as operation, application package name, and URI, and to receive a reply from the remote device's launched application.

The remote application can be launched in 2 ways:

  • Explicit launch: The remote application can be launched by explicitly defining the package and application name of the remote application in the app control request.
  • Implicit launch: The remote application can be launched implicitly by defining the operation and URI of the remote application in the app control request.

You can use either of the launch methods, based on the available knowledge of remote application attributes, such as the package name, application name, operation, and URI.

Prerequisites

To use the Remote App Control API, the application has to request permission by adding the following privileges to the config.xml file:

<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
<tizen:privilege name="http://developer.samsung.com/tizen/privilege/accessoryprotocol"/>

Creating and Launching Explicit Remote App Control Object

If you know the remote application package and application names, you can use the explicit launch method:

  1. Create a RemoteApplicationControl object with the operation, package name, application name, and optional data. The optional data is an additional private string that is sent to the application in the remote device.

    Currently, the http://samsung.com/appcontrol/operation/remote/default operation is supported to explicitly launch a remote application. This case, you no URI (second parameter) needs to be set.

    var explicitRemoteAppCtrl = new webapis.RemoteApplicationControl("http://samsung.com/appcontrol/operation/remote/default",
                                                                     null,
                                                                     "com.example.yourpkg",
                                                                     "com.example.yourpkg.MainActivity",
                                                                     "Hello World!");
    
  2. Launch the remote application explicitly by using the launchRemoteAppControl() method of the RemoteAppControlManager interface.

    Define callbacks that are called based on whether the launch request succeeds or fails.

    To receive reply data from the launched application in the remote device, use the RemoteAppControlReplyCallback interface to define applicable event handlers. The RemoteAppControlReplyCallback interface requires both success and error event handlers.

    var remoteAppControlReplyCallback = 
    {
       /* Launched application sent a reply */
       onsuccess: function(data)
       {
          console.log('Received data is ' + data);
       },
       /* Remote device returned a failure */
       onfailure: function()
       {
          console.log('The remote application control launch failed');
       }
    }
    
    try
    {
       webapis.remoteappcontrol.launchRemoteAppControl(explicitRemoteAppCtrl,
                                                       function() {console.log("success");}, 
                                                       function(e) {console.log("failed: " + e.name);}, 
                                                       remoteAppControlReplyCallback);
    }
    catch (e)
    {
       console.log("Error Exception, error name: " + e.name + ", error message: " + e.message);
    }
    

Creating and Launching Implicit Remote App Control Object

If you know the operation and URI registered by the remote application, you can use the implicit launch method:

  1. Create a RemoteApplicationControl object with the operation and URI.

    Currently, the http://samsung.com/appcontrol/operation/remote/view operation is supported to implicitly launch a remote application with a URI.

    var implicitRemoteAppCtrl = new webapis.RemoteApplicationControl("http://samsung.com/appcontrol/operation/remote/view",
                                                                     "https://developer.tizen.org/");
    
  2. Launch the remote application implicitly by using the launchRemoteAppControl() method of the RemoteAppControlManager interface.

    Define callbacks that are called based on whether the launch request succeeds or fails.

    The process is identical to the explicit launch, expect that you do not need to use the RemoteAppControlReplyCallback interface to receive a reply.

    try
    {
       webapis.remoteappcontrol.launchRemoteAppControl(implicitRemoteAppCtrl,
                                                       function() {console.log("success");}, 
                                                       function(e) {console.log("failed: " + e.name);});
    }
    catch (e)
    {
       console.log("Error Exception, error name: " + e.name + ", error message: " + e.message);
    }
    
Go to top