How to start an application using android ADB tools?

后端 未结 11 1195
醉酒成梦
醉酒成梦 2020-11-22 07:23

How do I send an intent using Android\'s ADB tools?

11条回答
  •  孤独总比滥情好
    2020-11-22 08:01

    linux/mac users can also create a script to run an apk with something like the following:

    create a file named "adb-run.sh" with these 3 lines:

    pkg=$(aapt dump badging $1|awk -F" " '/package/ {print $2}'|awk -F"'" '/name=/ {print $2}')
    act=$(aapt dump badging $1|awk -F" " '/launchable-activity/ {print $2}'|awk -F"'" '/name=/ {print $2}')
    adb shell am start -n $pkg/$act
    

    then "chmod +x adb-run.sh" to make it executable.

    now you can simply:

    adb-run.sh myapp.apk

    The benefit here is that you don't need to know the package name or launchable activity name. Similarly, you can create "adb-uninstall.sh myapp.apk"

    Note: This requires that you have aapt in your path. You can find it under the new build tools folder in the SDK.

提交回复
热议问题