The following bash script can be used to display the package and activity names in an apk, and launch the application by passing it an APK file.
apk_start.sh
package=`aapt dump badging $* | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
activity=`aapt dump badging $* | grep Activity | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
echo
echo package : $package
echo activity: $activity
echo
echo Launching application on device....
echo
adb shell am start -n $package/$activity
Then to launch the application in the emulator, simply supply the APK filename like so:
apk_start.sh /tmp/MyApp.apk
Of course if you just want the package and activity name of the apk to be displayed, delete the last line of the script.
You can stop an application in the same way by using this script:
apk_stop.sh
package=`aapt dump badging $* | grep package | awk '{print $2}' | sed s/name=//g | sed s/\'//g`
adb shell am force-stop $package
like so:
apk_stop.sh /tmp/MyApp.apk
Important Note: aapt can be found here:
<android_sdk_home>/build-tools/android-<ver>/aapt