Learning to receive notifications when the list of installed applications changes allows you to manage all the device applications from your application:
-
Define the event handlers for different notifications using the ApplicationInformationEventCallback listener interface:
var appEventCB = { /* When new applications are installed */ oninstalled: function(application) { console.log("Application " + application.name + " installed"); } /* When applications are updated */ onupdated: function(application) { console.log("Application " + application.name + " updated"); } /* When applications are uninstalled */ onuninstalled: function(appid) { console.log("Application " + appid + " uninstalled"); } }
-
Register the listener to use the defined event handlers:
var listenerID = webapis.application.addAppInfoEventListener(appEventCB);
-
To stop the notifications, use the removeAppInfoEventListener() method of the ApplicationManager interface:
webapis.application.removeAppInfoEventListener(listenerID);