This article provides some guidance and examples of commands that can be sent through the command interface to Android Devices. To see example commands for Windows and Linux Devices, see the following articles:
If a supplied command does not return within 60 seconds, the UI will display a timeout message.
If a command does not return at all (e.g. it spawns a sub-prompt for further input), subsequent use of the command interface will fail until 5 minutes has passed. At this point, the interface kills the process so that further commands are possible.
Starting an App
To start an app using the Monkey tool:
monkey -p com.company.package_name -c android.intent.category.LAUNCHER 1
For more information on the monkey command line tool, see the following android.com developer page:
In cases where the monkey tool is not available, the Activity Manager may be used instead, as follows:
am start -n com.company.package_name/.activity_name
Note that both the package name and activity name are required, and the activity name should be the LAUNCHER category activity. This is typically (though not always) MainActivity.
Some experimentation may have to be done to find out which activity is the root LAUNCHER activity. For example, use “dumpsys” to list all of the activities in a given package, as follows:
dumpsys package | grep package_name | grep Activity
Stopping an App
Use the following command to stop an application using the package name:
am force-stop com.company.package_name
Listing installed packages
To see a list of the available packages installed on a device, use the Android Package Manager, as follows:
pm list packages -3
Note that the -3 option will list only third party apps. To list the built in application package names, remove the -3 option.
Make a new directory
rm -rf /data/data/tmp/CustomApp
Remove a directory
Run a custom script
Android Agent Command Line Escape Sequences
The following commands have been added to the Android SquareOne Agent to add useful features that are not natively provided by the Android shell.
Please note that if one of the following escape sequences is found in the command line, it will be intercepted and only the escape sequence will be processed. This also means that shell features such as piping or I/O redirection will not be available.
--update_package: OTA Update Package
--start_app: Start An Application
Usage: --start_app=<Application ID>
The start_app command will use the Android Activity Manager () to start an Android Java Application. The “com.company.app” is the Android Application ID that uniquely identifies an Android Application ().
--stop_app: Stop An Application
Usage: --stop_app=<Application ID>
The stop_app command will use the Android Activity Manager () to stop an Android Java Application. The “com.company.app” is the Android Application ID that uniquely identifies an Android Application ().
--delayed_reboot: Delayed Reboot
Usage: --delayed_reboot=<delay time in seconds>
The delayed_reboot command will start a background process which reboots the device after the provided number of seconds have elapsed. This is an asynchronous process that allows communications to continue while reboot is prepared.
--get_process_list: Get Java Application Process List
The get_proccess_list command returns a list of Application IDs for the Java applications currently running. Each item in the list will be separated with a “\r\n”.