I found a way to get the APK's package name in a non-root device.
it's not so elegant, but works all the time.
Step 1: on your device, open the target APK
Step 2: on PC cmd window, type this commands:
adb shell dumpsys activity a > dump.txt
because the output of this command is numerous, redirect to a file is recommended.
Step 3: open this dump.txt file with any editor.
for device befor Android 4.4:
the beginning of the file would be looked like this:
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Main stack:
* TaskRecord{41aa9ed0 #4 A com.tencent.mm U 0}
numActivities=1 rootWasReset=true userId=0
affinity=com.tencent.mm
intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10600000 cmp=com.tencent.mm/.ui.LauncherUI}
realActivity=com.tencent.mm/.ui.LauncherUI
askedCompatMode=false
lastThumbnail=null lastDescription=null
lastActiveTime=19915965 (inactive for 10s)
* Hist #9: ActivityRecord{41ba1a30 u0 com.tencent.mm/.ui.LauncherUI}
packageName=com.tencent.mm processName=com.tencent.mm
the package name is in the 3rd line, com.tencent.mm for this example.
for Android 4.4 and later:
the dumpsys output has changed a little.
try search "Stack #1", the package name would be very close below it.
Also, search "baseDir", you will find the full path of the apk file!