问题
I'm trying to start an installed app with dalvikvm in terminal. It doesn't work if I try to do this just so:
dalvikvm -cp /system/app/Calculator.apk com.android.calculator2/.Calculator
Then comes failure message : dalvikvm cannot find a main class
So I tried to run an "am start" in dalvikvm:
dalvikvm -cp system/framework/am.jar com.android.commands.am.Am
It really works. But if I trying then to start an app:
dalvikvm -cp system/framework/am.jar com.android.commands.am.Am start -n com.android.calculator2/.Calculator
it doesn't work.
Can somebody help me please?
回答1:
A couple of points:
You cannot run an android application from the terminal. In your first command, it would execute a static void main(String[]) method in the Calculator class, if there were one. It's not possible to "execute" an application in this manner.
Using am is the correct way to start a specific activity from the terminal. You can simply use the provided "am" script (/system/bin/am). Or at least look at that script to see how to correctly invoke am.
For example, am start -n com.android.calculator2/.Calculator
should do what you want
回答2:
You can run dalvikvm headless with vogar. You'll have to build it from SVN; the prebuilt jar is out of date!
来源:https://stackoverflow.com/questions/8873537/terminal-run-dalvikvm-with-am-jar