Android Agent JavaScript

Android Agent JavaScript is a domain-specific language, which is comprised of two parts:

  1. JavaScript Engine
  2. Android Agent JavaScript APIs

The following code snippet illustrates both parts:

// Stop clock app if it runs in the foreground
var clockApp = 'com.android.deskclock';
var foregroundActivities = mobicontrol.app.foregroundActivities;
if (foregroundActivities != null) {
    foregroundActivities.forEach(function(activity) {
        if (activity.packageName == clockApp) {
            mobicontrol.app.stop(clockApp);
        }
    });
}

The JavaScript engine provides core language functionality, such as an if statement or forEach array function, while mobicontrol.app.foregroundActivities and mobicontrol.app.stop are Android Agent JavaScript APIs.

JavaScript Engine

Generally, most people use JavaScript to add scripts to their HTML web pages. However, the agent has an implementation of the core language only and doesn't contain objects or methods for manipulating HTML documents.

The agent supports the JavaScript language as standardized by Standard ECMA-262 ECMAScript. The agent's JavaScript engine conforms to Edition 3 of the standard, and partially supports features of Editions 4 and higher, see Advanced ECMA Feature Support.

Android Agent JavaScript APIs

Android Agent JavaScript APIs enhance the JavaScript engine with device management capabilities.
The APIs are grouped by functionality into namespaces. For example, APIs covering the app control functionality, like starting or installing an app, can be found in the mobicontrol.app namespace; APIs covering file operations - in the mobicontrol.io namespace, etc.
This documentation provides a reference for each Android Agent JavaScript API, like mobicontrol.app.install or mobicontrol.io.File.

Tutorials

The documentation provides several tutorials on how to use Android Agent JavaScript. For example, JavaScript Modules tutorial explains how to use third-party or in-house JavaScript modules/libraries; ErrorHandling tutorial teaches error handling techniques, Data Formats tutorial shows how to read and write XML and JSON files.
Readers can switch between API references and tutorials by selecting a corresponding tab in the left-side panel.

Release Notes

Release Notes provides the history of Android Agent JavaScript releases.

The document describes the major features of each release and explains the correspondence between Android Agent JavaScript and Android Agent releases.