android開發adb shell ps無法列出程序列表的解決方法
阿新 • • 發佈:2022-12-12
問題:
C:\WINDOWS\System32>adb shell ps
USER PID PPID VSZ RSS WCHAN ADDR S NAME
shell 16817 2271 2133456 3336 0 0 R ps
發現並沒有列出手機app的程序列表呀
解決方法:
使用C:\WINDOWS\System32>adb shell ps --help #新增--help就可以檢視需要新增的引數 顯示幫助如下: Which processes to show (-gGuUpPt selections may be comma separated lists): -A All#顯示全部 -a Has terminal not session leader -d All but session leaders -e Synonym for -A -g In GROUPs -G In real GROUPs (before sgid) -p PIDs (--pid) -P Parent PIDs (--ppid) -s In session IDs -t Attached to selected TTYs -T Show threads also -u Owned by selected USERs -U Real USERs (before suid) Output modifiers: -k Sort FIELDs (-FIELD to reverse) -M Measure/pad future field widths -n Show numeric USER and GROUP -w Wide output (don't truncate fields) Which FIELDs to show. (-o HELP for list, default = -o PID,TTY,TIME,CMD) -f Full listing (-o USER:12=UID,PID,PPID,C,STIME,TTY,TIME,ARGS=CMD) -l Long listing (-o F,S,UID,PID,PPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD) -o Output FIELDs instead of defaults, each with optional :size and =title -O Add FIELDS to defaults -Z Include LABEL
所以使用adb shell ps -A 即可顯示所有程序,adb shell ps -Af 即可顯示所有程序的所有資訊了
列出自己需要的程序資訊可以可以結合grep命令:adb shell "ps -Af | grep com.suyf.demo" #com.suyf.demo是自己app的包名獲取其他關鍵字也可以,grep就是搜尋的意思