用一套方法論去設計許多方法來解決工程上遇到的問題。 即 "一生萬法、萬法圓通"。

Recent in Recipes

3/Food/post-list

Get an activity name of a package and launch it

沒有留言

Older Android

adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

Newer Android Q

adb shell "dumpsys activity activities | grep mResumedActivity"

referring to: https://stackoverflow.com/questions/13193592/adb-android-getting-the-name-of-the-current-activity

Class name

Once the package name has been found (for example com.symbol.wfc.voice), the class name of the main activity has to be determined.

To find all activities published by a package, use the following command & replace com.symbol.wfc.voice by the name of the package to process.
adb shell [enter] dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+com.symbol.wfc.voice/[^[:space:]]+" | grep -oE "[^[:space:]]+$"

referring to: https://www.zebra.com/us/en/support-downloads/knowledge-articles/evm/Using-ADB-to-Determine-Package-Name-and-Launchable-Activity.html

Package name

To list only 3rd party application
adb shell pm list packages -3

啟動應用程式

格式:am start -n package name / activity name
adb2 shell am start -n com.android.calculator2/com.android.calculator2.Calculator

不管幾層,立馬回到Home畫面

adb2 shell am start -a android.intent.action.MAIN -c android.intent.category.HOME
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] }
Warning: Activity not started, its current task has been brought to the front

沒有留言 :

張貼留言