Android custom commands

Custom commands allow you to execute remote actions on managed Android devices.

In addition to default device actions available in the MaaS360 Portal, you can use custom commands to execute dynamic actions on managed devices. After sending a custom command, you can track the execution status of all commands in the Device History page in the MaaS360 Portal. Note: This feature requires MaaS360 for Android app version 7.40 or later.

Supported custom commands

The following table describes the custom commands that are supported in MaaS360:
Action Description Command
Enable kiosk mode Launches kiosk mode on the devices.
The following requirements must be met:
  • Kiosk mode is not already activated on the target devices.
  • Silent enablement is allowed.
  • Kiosk mode is enabled in the MDM policies.
enable-kiosk
Launch app Launches the specified app on the device.
The following requirement must be met:
  • The target app must be installed on the device.
launch-app <package name>. Examples:
  • launch-app com.google.android.gm
  • launch-app us.zoom.videomeetings
Start activity Starts an instance of the activity specified by the intent.
Device support:
  • Device Admin: Android 9 or lower versions
  • Profile Owner : Android 9 or lower versions
  • Device Owner : All OS versions
  • Work Profile on Corporate Owned (WPCO) : Not supported
The following requirements must be met:
  • For explicit intents, you can only start the activities of the packages that are installed on the device.
start-activity <intent options>
Start broadcast Broadcast the specified intent to the device. send-broadcast <intent options>
Clear app data Clears app data. This command supports multiple app IDs.
Requirements:
  • Requires MaaS360 for Android app version 7.60 or later.
  • Supported only on Android Enterprise devices running OS version 9 or later.
  • The action fails if the target apps are not installed on the device.
clear-app-data <comma-separated app IDs>
  • clear-app-data com.ibm.security.verifyapp, com.ibm.gts.banorte.epass

Intent options

The following table describes the supported intent options with the sample commands:
Intent options Description Example
-a Set the action on the intent
  • start-activity -a android.intent.action.VIEW: Lists the apps that support this action.
  • send-broadcast -a 'my_action': Broadcasts the action on the Android OS. Apps can use the action if the action is registered on the app.
  • send-broadcast -a 'my_action' -n com.example.sampleapp/.MyActivity -es EXTRA "SampleData": Sends the broadcast "my-action" to the activity "MyActivity" of the sample app with the string data in the form of a key-value pair (key: "EXTRA" value: "SampleData").
-c Add a category to an intent start-activity -c android.intent.category.HOME -a android.intent.action.MAIN: Launches the Home screen.
-d Set the data URL on the intent start-activity -a android.intent.action.VIEW -d http://www.google.com: Opens google.com in a browser app. The command fails if a browser app is not installed.
-t Set the MIME type on the intent start-activity -t image/* -a android.intent.action.VIEW: Opens the Gallery or any app that displays images. A list of apps is displayed if there are multiple apps available.
-n Set the specific intent component start-activity -n com.example.sampleapp/.SaveFileActivity: Opens the sample app's Save File screen. Note: If "SaveFileActivity" is not exported, the command fails.

-es, -eb, -ei, -ed, -en, -eia, -esa, -eba, -eda

Note: For string data, you must use quotes around the string to specify the value.

Add data/extras as a key-value pair to intent

-es - String

start-activity -n com.example.sampleapp/.MyActivity -es EXTRA "Life is Great": Opens the specific activity "MyActivity" and sends the string data in the form of a key-value pair (key: "EXTRA" value: "Life is Great") to the activity. Note: If "MyActivity" is not exported, the command fails.

-eb - Boolean

start-activity -n com.example.sampleapp/.MyActivity -eb Status true: Opens the specific activity "MyActivity" and sends the boolean data in the form of a key-value pair (key:"Status" value: true) to the activity. Note: If "MyActivity" is not exported, the command fails.

-ed - Double/Float

start-activity -n com.example.sampleapp/.MyActivity -ed Code 999.9878: Opens the specific activity "MyActivity" and sends the double/float data in the form of a key-value pair (key:"Code" value: 999.9878) to the activity. Note: If "MyActivity" is not exported, the command fails.

-ei - Integer

start-activity -n com.example.sampleapp/.MyActivity -ei Code 999: Opens the specific activity "MyActivity" and sends the integer data in the form of a key-value pair (key:"Code" value: 999) to the activity. Note: If "MyActivity" is not exported, the command fails.

-esa - String Array

start-activity -n com.example.sampleapp/.MyActivity -esa Months "[Jan,Feb,March]": Opens the specific activity "MyActivity" and sends the string array data in the form of a key-value pair (key: "Months" value: "[Jan,Feb,Mar]") to the activity. Note: If "MyActivity" is not exported, the command fails.

-eba - Boolean Array

start-activity -n com.example.sampleapp/.MyActivity -eba Status [true, false, false, false] : Opens the specific activity "MyActivity" and sends the boolean array data in the form of a key-value pair (key:"Status" value: [true, false, false, false]) to the activity. Note: If "MyActivity" is not exported, the command fails.

-eda - Double/Float Array

start-activity -n com.example.sampleapp/.MyActivity -eda Codes [10.33, 12.33, 14.33, 15.33]: Opens the specific activity "MyActivity" and sends the double/float array data in the form of a key-value pair (key:"Codes" value: [10.33, 12.33, 14.33, 15.33]) to the activity. Note: If "MyActivity" is not exported, the command fails.

-eia - Integer Array

start-activity -n com.example.sampleapp/.MyActivity -eia Codes [998, 999, 1000]: Opens the specific activity "MyActivity" and sends the integer array data in the form of a key-value pair (key:"Codes" value: [998, 999, 1000]) to the activity. Note: If "MyActivity" is not exported, the command fails.

-en - Null

start-activity -n com.example.sampleapp/.MyActivity -en DataValue null: Opens the specific activity "MyActivity" and sends the null data in the form of a key-value pair (key: "DataValue" value: null) to the activity. Note: If "MyActivity" is not exported, the command fails. If you want to pass null, use the -en option. If you use other options to pass null, the command fails.

Custom command requirements

  • The angle brackets < and > are not supported.
  • You cannot use the word "script", and the signs "&lt" and "&gt" more than once.
  • The maximum character limit is 2500.

Pushing custom commands to devices

You can issue custom commands to an individual device or a group of devices.

To send custom commands to an individual device:
  1. Go to Device > Summary and then select a device. The Device Summary page is displayed.
  2. Click More and then select Android Custom Command.
  3. Enter the custom command and then click Run.
To send custom commands to a group of devices:
  1. Go to Devices > Groups.
  2. Hover over the More option below the device group and then select Manage Android Devices. The Manage Android Devices window is displayed.
  3. Select Android Custom Command in the Action drop-down field.
  4. Enter the custom command and then click Run.
    Custom commands group

Tracking the execution status of commands

You can view the execution status of all the commands that were issued to the selected device in the Device History page.

When the custom command is executed, the following statuses are returned:
  • Completed: The action is successfully implemented on the device.
  • Error: The action failed to execute and more details are provided under the Error Description column.
Android custom command