Have you ever wanted to launch an Android app from the shell, but you were confused as to how to go about it? Me too, but after a bit of searching about I found a couple of posts that explain how to do it. Short short form, you use aapt to find the activity you want to execute, and then you can use the am command (on the device) to launch the program.
As you probably know, Android apps are more or less Java programs. These programs are packed up in JAR files for normal Java or in APKs for Android, both of which are just ZIP archives with some additional fancy files which give them meaning. In the case of Android, you need to understand the AndroidManifest.xml file, but these are binary files which you are unlikely to comprehend when viewed by eye. But you can use the aapt command to list activities within the APK in order to figure out how to launch the program.
aapt is part of the Android SDK. I'm not going to cover how to install that, but you only need the tools and platform tools in order to accomplish this task. On my personal Ubuntu system, the sdk is installed in /opt/android-sdk-linux and aapt is in /opt/android-sdk-linux/platform-tools. If you can't just type "aapt" and get something other than command not found, you can add this (or whatever) directory to your path or you can just type the path. Either way, you want to fetch the APK from your device, perhaps with adb pull, and then do something like this:
aapt dump xmltree jp.ne.neko.freewing.BluetoothOnOff-1.apk \
AndroidManifest.xml | less
This is a real example; I was trying to figure out how to efficiently toggle bluetooth on Ouya from ADB. The resulting output looks like this:
E: manifest (line=2)
A: android:versionCode(0x0101021b)=(type 0x10)0x5
A: android:versionName(0x0101021c)="1.4" (Raw: "1.4")
A: android:installLocation(0x010102b7)=(type 0x10)0x2
A: package="jp.ne.neko.freewing.BluetoothOnOff" (Raw: "jp.ne.neko.freewing.BluetoothOnOff")
E: application (line=10)
E: activity (line=11)
A: android:name(0x01010003)="BluetoothOnOff" (Raw: "BluetoothOnOff")
E: intent-filter (line=15)
E: action (line=16)
A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
E: category (line=17)
A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
The output continues on from here, but this is the interesting part. We know that our app's full true name is
jp.ne.neko.freewing.BluetoothOnOff and that the "name" of the MAIN intent is
BluetoothOnOff. So now we can issue the am command with adb:
adb shell am start jp.ne.neko.freewing.BluetoothOnOff/.BluetoothOnOff
For me, this successfully ran the program and toggled bluetooth.