mobicontrol.app

This namespace provides access to app control properties, like starting or installing app.
Since:
  • Version 1.0 (API level 1)

Members

static, readonly, nullable foregroundActivities :Array.<mobicontrol.app.Activity>

Array of the foreground activities.

This array is null if the agent cannot obtain the list of the foreground activities. This might happen, for example, if the agent doesn't have the proper permissions.

Since:
  • Version 1.0 (API level 1)
Example
// 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);
        }
    });
}

static, readonly InstallationStatusCode :object

Holds possible return status codes for mobicontrol.app.install.
Properties:
Name Type Description
NONE object No specific status code.
ALREADY_INSTALLED object Same version of the app is already installed.
FILE_NOT_FOUND object .apk file was not found.
VERSION_DOWNGRADE object Attempt to downgrade already installed app failed.
APK_FORMAT_NOT_CORRECT object .apk file format is not correct. This includes cases where the .apk file is incompatible with the device's OS.
Since:
  • Version 1.0 (API level 1)

Methods

async, static install(apkFilePath, callbackFunctionopt, invocationTimeoutInMillisopt) → {boolean}

Install an app.

If the app (same version) is already installed, no action is taken and the function returns true. If app installation isn't possible, the function returns false. For example, app installation might not be possible if one of the following conditions exists:

  • The .apk file does not exist.
  • The .apk file has a wrong format.
  • A later version of the app is already installed.
Otherwise, the function returns true and the installation process is asynchronously launched. Note that the installation might still fail, even if the function returned true.

If a callback function parameter is supplied, it will be called when the installation attempt completes, with an argument describing the result of the installation attempt.

Parameters:
Name Type Attributes Default Description
apkFilePath string The path to the .apk (for example, /data/example.apk).
callbackFunction mobicontrol.app.installCallback <optional>
JavaScript function which is called when the installation attempt completes.
invocationTimeoutInMillis number <optional>
60000 Invocation timeout in milliseconds. If the callback function isn't invoked before the timeout expires, it will be called with the timed-out result.
Returns:
boolean - True if the app installation process was successfully launched, false otherwise.
Since:
  • Version 1.0 (API level 1)
Example
// Install an app and start it as soon as it has been installed
mobicontrol.app.install('/sdcard/example.apk', onFinish);

function onFinish(result) {
    if (result.isSuccessful) {
        mobicontrol.app.start('net.soti.example');
    }
}

async, static start(packageName, classNameopt) → {boolean}

Start an app.
Parameters:
Name Type Attributes Description
packageName string The package name of the app to start.
className string <optional>
The fully qualified class name of the specific component of the app.
Returns:
boolean - True if the app starting process was succesfully launched, false otherwise.
Since:
  • Version 1.0 (API level 1)
Example
// Start 'MyActivity' activity of the 'com.example' app
mobicontrol.app.start('com.example', 'com.example.app.MyActivity');

async, static stop(packageName) → {boolean}

Stop an app.
Parameters:
Name Type Description
packageName string The package name of the app to be stopped.
Returns:
boolean - True if the app stop process was successfully launched.
Since:
  • Version 1.0 (API level 1)
Example
// Stop app with 'com.example' package name
mobicontrol.app.stop('com.example');

Type Definitions

Activity

Android activity information
Properties:
Name Type Description
packageName string Package name of activity
className string Class name of activity
Since:
  • Version 1.0 (API level 1)

installCallback(result)

Callback function for mobicontrol.app.install
Parameters:
Name Type Description
result object Result of the installation attempt.
Properties
Name Type Description
apkFileName string The .apk file of application being installed
statusCode mobicontrol.app.InstallationStatusCode The detailed status code of the callback.

Follow the link in the Type column to see all the possible values.

isSuccessful boolean Success status of the callback.

True if the callback completed successfully, false otherwise.

isTimedOut boolean Timeout status of the callback.

True if the callback was timed out, false otherwise.

Note: A timeout is considered a failure, so if the timeout status is true, failure status is true as well, and success status is false.

isFailed boolean Failure status of the callback.

True if the callback failed, false otherwise.

Since:
  • Version 1.0 (API level 1)