Is there a way to get the launchable activity for a package from using adb
? For an unroot phone (i.e. without having the pull the apk from /data/
You don't need root to pull the apk files from /data/app
. Sure, you might not have permissions to list the contents of that directory, but you can find the file locations of APKs with:
adb shell pm list packages -f
Then you can use adb pull
:
adb pull <APK path from previous command>
and then aapt
to get the information you want:
aapt dump badging <pulledfile.apk>
Launch your app and keep it in foreground.
Run the below command:
adb shell dumpsys window windows | find "mcurrentfocus"
$ adb shell pm dump PACKAGE_NAME | grep -A 1 MAIN
Here is another way to find out apps package name and launcher activity.
Step1: Start "adb logcat" in command prompt.
Step2: Open the app (either in emulator or real device)
Since Android 7.0 you can use adb shell cmd package resolve-activity
command to get the default activity of an installed app like this:
adb shell "cmd package resolve-activity --brief com.google.android.calculator | tail -n 1"
com.google.android.calculator/com.android.calculator2.Calculator
You can also use ddms for logcat logs where just giving search of the app name you will all info but you have to select Info instead of verbose or other options. check this below image.