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

相关推荐
2501_915918419 分钟前
iOS 26 App 性能测试|性能评测|iOS 26 性能对比:实战策略
android·macos·ios·小程序·uni-app·cocoa·iphone
咋吃都不胖lyh4 小时前
SQL-多对多关系
android·mysql·数据分析
cyy2984 小时前
android 屏幕适配
android
Digitally6 小时前
如何通过 5 种有效方法同步 Android 和 Mac
android·macos
行墨8 小时前
Jetpack Compose 深入浅出(二)——基础组件Text
android
雨白9 小时前
深入理解协程的运作机制 —— 调度、挂起与性能
android·kotlin
沐怡旸9 小时前
【Android】Android系统体系结构
android
namehu10 小时前
React Native 应用性能分析与优化不完全指南
android·react native·ios
xqlily10 小时前
Kotlin:现代编程语言的革新者
android·开发语言·kotlin
HelloBan10 小时前
如何正确去掉SeekBar的Thumb和按压效果
android