Skip to content

Instantly share code, notes, and snippets.

@housemeow
Created September 14, 2015 02:43
Show Gist options
  • Save housemeow/765c1b788e34ff7009ca to your computer and use it in GitHub Desktop.
Save housemeow/765c1b788e34ff7009ca to your computer and use it in GitHub Desktop.
如何利用adb shell開啟指定的app 依循以下步驟操作
首先要能夠得知要開啟app的Activity
http://stackoverflow.com/questions/13193592/adb-android-getting-the-name-of-the-current-activity
利用adb shell dumpsys activity來取得目前所有的activity
可以用這樣的指令 把輸出導到檔案內adb shell dumpsys activity > activity.txt
假如我是要找color note 我搜尋color找到這段
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)當中的
realActivity = com.socialnmobile.dictapps.notepad.color.note/com.socialnmobile.colornote.activity.Main
這就是color note的activity
接下來就簡單了!就利用剛剛抓到的activity來啟動
在adb shell內執行:
am start -n com.socialnmobile.dictapps.notepad.color.note/com.socialnmobile.colornote.activity.Main
在cmd內執行:
adb shell am start -n com.socialnmobile.dictapps.notepad.color.note/com.socialnmobile.colornote.activity.Main
在python內執行:
import os
os.system("adb shell am start -n com.socialnmobile.dictapps.notepad.color.note/com.socialnmobile.colornote.activity.Main ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment