1

What I have:

  1. I have application installed in device
  2. I have a Mac system and I am using terminal
  3. I am connected to device via terminal

What I am trying to do:

  1. I am trying to launch the installed application via terminal ( I don't want to reinstall the app and run )
  2. I need to find the app via package name and run it

What I have tried:

admins-MacBook-Pro:platform-tools devrath$ ./adb shell monkey -p com.cnx.dictionary -c android.intent.category.LAUNCHER 1

Error I am getting:

** No activities found to run, monkey aborted.
Devrath
  • 42,072
  • 54
  • 195
  • 297

1 Answers1

0

To find the package, use adb shell pm list packages. There will more than likely be a lot of packages listed. If you know a part of the package name, you can use grep to limit your results. If you were looking for the Facebook package name, you could use adb shell pm list packages | grep facebook and it would only show results with facebook in it.

From there, you need you find the class to start.

  1. adb shell
  2. dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+com.packagename/[^[:space:]]+" | grep -oE "[^[:space:]]+$" (make sure you change the "com.packagename" part to the name of your package.
  3. Find the class you want to use from the output list. Most apps will have a class of .SplashActivity, .HomeActivity, or .Main but you will have to find the one for your app
  4. When you have that, use am start -n com.packagename/.Class where your package name replaces com.packagename and the class you chose replaces .Class.

One thing to note. In step 1, we used the command adb shell so we are in the of the android device issuing the commands after. If you are issuing the am start command at the main terminal screen, you will have to add adb shell before am start.

I used the zebra site a while back to get this info initially so i left it here for your reference as well.