How do I send an intent using Android\'s ADB tools?
We can as well start an application by knowing application type and feeding it with data:
adb shell am start -d "file:///sdcard/sample.3gp" -t "video/3gp" -a android.intent.action.VIEW
This command displays available Video Players to play sample.3gp file
adb shell
am start -n com.package.name/com.package.name.ActivityName
Or you can use this directly:
adb shell am start -n com.package.name/com.package.name.ActivityName
You can also specify actions to be filter by your intent-filters:
am start -a com.example.ACTION_NAME -n com.package.name/com.package.name.ActivityName
monkey --pct-syskeys 0
for development boards
Without this argument, the app won't open on a development board without keys / display:
adb shell monkey --pct-syskeys 0 -p com.cirosantilli.android_cheat.textviewbold 1
and fails with error:
SYS_KEYS has no physical keys but with factor 2.0%
Tested on HiKey960, Android O AOSP.
Learned from: https://github.com/ARM-software/lisa/pull/408
Also asked at: monkey test : If the Android system doesnt has physical keys ,what are the parameters need to be includeded in the command
It's possible to run application specifying package name only using monkey tool by follow this pattern:
adb shell monkey -p your.app.package.name -c android.intent.category.LAUNCHER 1
Command is used to run app using monkey tool which generates random input for application. The last part of command is integer which specify the number of generated random input for app. In this case the number is 1, which in fact is used to launch the app (icon click).
Step 1: First get all the package name of the apps installed in your Device, by using:
adb shell pm list packages
Step 2: You will get all the package names, copy the one you want to start using adb.
Step 3: Add your desired package name in the below command.
adb shell monkey -p 'your package name' -v 500
For Example:
adb shell monkey -p com.estrongs.android.pop -v 500
to start the Es explorer.
open ~/.bash_profile and add these bash functions to the end of the file
function androidinstall(){
adb install -r ./bin/$1.apk
}
function androidrun(){
ant clean debug
adb shell am start -n $1/$1.$2
}
then open the Android project folder
androidinstall app-debug && androidrun com.example.app MainActivity