adb 发送广播 && 恢复出厂

adb 发送广播 && 恢复出厂

发送广播

adb shell am broadcast -a 广播名android.intent.action.BOOT_COMPLETED

这条命令可以更精确的发送到某个package,如下:

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name

启动activity/service

在adb shell中,通过am命令行启动一个Activity程序:

从superuser源代码中摘录一段使用示例:

adb shell am start -a android.intent.action.MAIN -n com.koushikdutta.superuser/com.koushikdutta.superuser.SuperuserRequestActivity

这个示例中:

-a 表示action (android.intent.action.MAIN)

-n 表示packagename (com.koushikdutta.superuser)

SuperuserRequestActivity是对应的Activity name

关机

adb shell am broadcast -a android.intent.action.ACTION_SHUTDOWN -c android.intent.category.HOME -n com.andy.androidtest/.ShutdownBroadcastReceiver

恢复出厂设置

adb shell am broadcast -a android.intent.action.MASTER_CLEAR

10.0可以用下方法

1、

adb shell am broadcast -a android.intent.action.MASTER_CLEAR

adb shell "echo "--wipe_data\n--locale=en_US" > /cache/recovery/command"

adb shell setprop sys.powerctl reboot,recovery

2、

am broadcast -a android.intent.action.FACTORY_RESET -p android --es android.intent.extra.REASON MasterClearConfirm

相关推荐
Jomurphys17 分钟前
Kotlin - 类型别名 typealias
android·kotlin
Haha_bj26 分钟前
Flutter ——flutter_screenutil 屏幕适配
android·ios
Haha_bj44 分钟前
Flutter ——device_info_plus详解
android·flutter·ios
前端小伙计1 小时前
Android/Flutter 项目统一构建配置最佳实践
android·flutter
Mr_sun.2 小时前
Day09——入退管理-入住-2
android·java·开发语言
ujainu3 小时前
告别杂乱!Flutter + OpenHarmony 鸿蒙记事本的标签与分类管理(三)
android·flutter·openharmony
常利兵4 小时前
Android内存泄漏:成因剖析与高效排查实战指南
android
·云扬·4 小时前
MySQL 8.0 Redo Log 归档与禁用实战指南
android·数据库·mysql
野生技术架构师4 小时前
SQL语句性能优化分析及解决方案
android·sql·性能优化
doupoa5 小时前
内存指针是什么?为什么指针还要有偏移量?
android·c++