openApp( moduleId, version ) method

Launch the hybrid app with the given module ID and version.

The hybrid app will be opened on top of the hybrid app that is open when hwc.openApp is called. When the hybrid app that was opened with hwc.openApp exits, it will exit to the hybrid app that was open when hwc.openApp was called. It is possible to nest open hybrid apps, but it is best not to have too many nested hybrid apps (eg: recursively opening hybrid apps) because each open hybrid app takes up device memory.

Syntax

<static> openApp( moduleId, version ) → {number}

Parameters

Name Type Description
moduleId number Module id of the hybrid app.
version number Version of the hybrid app.

Returns

A constant indicating the result of opening the hybrid app (will be one of hwc.OPEN_APP_SUCCESS, hwc.OPEN_APP_NOT_EXIST, hwc.OPEN_APP_OTHER).

[/reference/refbody/section/sectiondiv {""})

Type:

number

(sectiondiv]

Example

var apps = hwc.getInstalledApps();
if( apps.length > 0 )
{
   // Check to make sure the first app is not this app (the app that is currently running),
   // since we don't want to recursively open this app until memory runs out.
   if( hwc.getCurrentHybridApp.getDisplayName() != apps[0].getDisplayName() )
   {
      hwc.openApp( apps[0].getModuleID(), apps[0].getVersion() );
   }
}

Source

hwc-api.js, line 1884.