This namespace provides access to the app control functionality, like starting or installing an app.
- Since:
Classes
Members
-
static, readonly AdminDeactivationStatusCode :object
-
This enumeration represents an error status code of [AppAdminDeactivationErrorHostObject].
Properties:
Name Type Description NOT_SUPPORTEDobject The device administrator deactivation is not supported by the current agent. NOT_INSTALLEDobject The specified app is not installed. NOT_PERMITTEDobject The device administrator deactivation is not permitted for the specified app. - Since:
-
static, readonly AppStatusCode :object
-
This enumeration represents an error status code of mobicontrol.app.AppError.
Properties:
Name Type Description UNKNOWNobject The exact error could not be determined. NOT_INSTALLEDobject The app is not installed. - Since:
-
static, readonly ClearDataStatusCode :object
-
This enumeration represents an error status code of mobicontrol.app.AppClearDataError.
Properties:
Name Type Description UNKNOWNobject The exact error could not be determined. NOT_SUPPORTEDobject Clear operation is not supported by the current agent. NOT_INSTALLEDobject The specified app is not installed. NOT_PERMITTEDobject Clearing the agent data can cause unrecoverable errors and is not permitted. - Since:
-
static, readonly, nullable foregroundActivities :Array.<mobicontrol.app.Activity>
-
Activities running in the foreground. This property is
nullif the list of the foreground activities cannot be obtained. This might happen, for example, if the agent doesn't have the proper permissions.- Since:
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
-
This enumeration represents a return status code of mobicontrol.app.install.
Properties:
Name Type Description NONEobject No specific status code. ALREADY_INSTALLEDobject Same version of the app is already installed. FILE_NOT_FOUNDobject .apk file was not found. VERSION_DOWNGRADEobject Attempt to downgrade already installed app failed. APK_FORMAT_NOT_CORRECTobject .apk file format is not correct. This includes cases where the .apk file is incompatible with the device's OS. - Since:
-
static, readonly, nullable installedApps :Array.<mobicontrol.app.App>
-
The array of apps installed on the device. This property is
nullif the list of the installed apps cannot be obtained.- Since:
Example
var installedApps = mobicontrol.app.installedApps; if (installedApps == null) { mobicontrol.log.error("Cannot obtain the list of installed apps"); } else { var installedAppPackageNames = installedApps .map(app => app.packageName) .join('|'); mobicontrol.log.info(installedAppPackageNames); }
Methods
-
async, static clearCache(packageName)
-
Clear app cache.
Parameters:
Name Type Description packageNamestring The package name of the app to be cleared. Throws:
- Since:
Example
mobicontrol.app.clearCache('com.example'); -
async, static clearData(packageName)
-
Clear app data.
Parameters:
Name Type Description packageNamestring The package name of the app to be cleared. Throws:
- Since:
Example
mobicontrol.app.clearData('com.example'); -
static deactivateAdmin(packageName) → {boolean}
-
Deactivates the admin rights. Deactivate device administrator for an app.
Parameters:
Name Type Description packageNamestring the package name of the app to be deactivated. Throws:
Returns:
boolean -trueif the device administrator for the app is deactivated,falseotherwise.- Since:
Example
mobicontrol.app.deactivateAdmin('com.example'); -
static getInstalledApp(packageName) → {mobicontrol.app.App}
-
Get the installed app by package name.
Parameters:
Name Type Description packageNamestring The app package name. Throws:
Returns:
mobicontrol.app.App - The installed app with the provided package name.- Since:
Example
if (mobicontrol.app.getInstalledApp("com.example").versionCode < 15000) { mobicontrol.log.error("The Example app is outdated; aborting script.") } -
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 returnsfalse. 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.
true, and the installation process is asynchronously launched. Note that the installation might still fail, even if the function has returnedtrue. 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 apkFilePathstring The path to the .apk (for example, "/data/example.apk"). callbackFunctionmobicontrol.app.installCallback <optional>
JavaScript function which is called when the installation attempt completes. invocationTimeoutInMillisnumber <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 -trueif the app installation process was successfully launched,falseotherwise.- Since:
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 packageNamestring The package name of the app to start. classNamestring <optional>
The fully qualified class name of the specific component of the app. Returns:
boolean -trueif the app starting process was succesfully launched,falseotherwise.- Since:
Example
mobicontrol.app.start('com.example', 'com.example.app.MyActivity'); -
async, static stop(packageName) → {boolean}
-
Stop an app.
Parameters:
Name Type Description packageNamestring The package name of the app to be stopped. Returns:
boolean -trueif the app stopping process was successfully launched,falseotherwise.- Since:
Example
mobicontrol.app.stop('com.example');
Type Definitions
-
Activity
-
This typedef represents an Android activity.
Properties:
Name Type Description packageNamestring Package name of this activity. classNamestring Class name of this activity. - Since:
-
installCallback(result)
-
Callback function for mobicontrol.app.install.
Parameters:
Name Type Description resultobject Result of the installation attempt. Properties
Name Type Description apkFileNamestring The .apk file of the application that is being installed. statusCodemobicontrol.app.InstallationStatusCode The detailed status code of the callback. Follow the link in the Type column to see all the possible values. isSuccessfulboolean Success status of the callback. trueif the callback completed successfully,falseotherwise.isTimedOutboolean Timeout status of the callback. trueif the callback was timed out,falseotherwise. Note: A timeout is considered a failure, so if the timeout status istrue, failure status istrueas well, and success status isfalse.isFailedboolean Failure status of the callback. trueif the callback failed,falseotherwise.- Since: