addAppListener( ApplicationListener, [containingObject] ) method

Register the application listener.

Syntax

<static> addAppListener( ApplicationListener, [containingObject] )

Parameters

Name Type Argument Description
ApplicationListener anonymous.ApplicationListener   The callback function for application changes.
containingObject Object (optional) The containing object of the listener method.This parameter is only required if the ApplicationListener references the containing object.

Example

// This is the callback function that will be passed to hwc.addAppListener.
var appListener = function( event, moduleId, version )
{
   if( event == hwc.APP_ADDED )
   {
      alert("A hybrid app has been added.");
   }
}
hwc.addAppListener( appListener );
// appListenerManager is an object that will contain the callback function as well as variables
// the callback function references.
var appListenerManager = {};
// doSomething is a function that is called from inside the callback function.
appListenerManager.doSomething = function( event )
{
   if( event == hwc.APP_REMOVED )
   {
      alert("A hybrid app has been removed.");
   }
}
// This is the callback function that will be passed to hwc.addAppListener.  It calls doSomething,
// the definition of which is in the containing function.
appListenerManager.listener = function( event, moduleId, version )
{
   this.doSomething( event );
}
// Since the listener callback function references a variable from its containing object,
// the containing object must be passed to hwc.addAppListener.
hwc.addAppListener( appListenerManager.listener, appListenerManager );

Source

hwc-api.js, line 1539.