adb shell am force-stop com.xiaopeng.privacyservice
adb shell am start-foreground-service -a com.xiaopeng.privacyservice.PrivacyService
可以写成批处理文件:
@echo off
echo " --- begin --- "
adb shell am force-stop com.xiaopeng.privacyservice
adb shell am start-foreground-service -a com.xiaopeng.privacyservice.PrivacyService
echo " --- end ---"
@REM pause
带参数发送广播:
adb shell am start -a android.intent.action.VIEW -d "xiaopeng://com.xiaopeng.privacyservice?action=showdialog\&type=201\&flag=0"
Android Adb Shell Command Record
[TOC]
本篇文章用于收集一些 Android 开发中常用的 Adb 命令。
当前 Activity
在接触一个陌生项目中,经常需要知道当前的 Activity 的信息。那么可以使用命令:
adb shell dumpsys activity top
, 可以的输出内容如下:(内容很多)可以获取当前 Activity 的一些信息。
查看启动耗时
在分析程序的冷启动时,经常需要获取程序的启动时间,可以使用如下命令:
adb shell am start -W -S package/avtivity
,比如:adb shell am start -W -S com.ziipin.softkeyboard.uzbekistan/com.ziipin.MainActivity
可以从上一步获取 package/activity。-W:等待启动完成 -S: 杀死当前 App 并启动
安装Apk
adb install -r path/xxx.apk
-r: 表示允许覆盖安装
-d: 表示允许降级覆盖安装
卸载应用
其中
<应用包名>
可以通过adb shell pm list packages
命令查看:adb shell pm list packages -s
可以查看系统应用adb shell pm list packages -3
可以查看用户应用adb shell pm list packages xxx
可以查看包含xxx
字符串的应用TAG 、Log级别过滤日志
例:
adb logcat MainActivity:D HomeFragemt:I
只输出TAG为MainActivity的Debug以上和 TAG为HomeFragemt的Info 以上的log日志,屏蔽其他的log日志;清空日志
adb logcat -c
内核日志
adb shell dmesg
查看手机分辨率
adb shell dumpsys window displays
清楚应用数据和缓存
在开发过程中,经常需要清楚数据,还原应用,可以使用:
adb shell pm clear pkgname
通过adb 命令启动重启service ,发送广播来进行调试
重启service:
可以写成批处理文件:
带参数发送广播:
参考资料:http://nky1989.com/2017/07/12/android-adb-shell-and-param/
调试修改[content provider]:参数见文档
查看文件的最后几行并过滤:
tail -f main.txt | grep RemoteMessageP
未完待续