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

相关推荐
我是场2 小时前
我的NPI项目之-Touch的EE特性
android·arm开发
天空之城--2 小时前
Android一周动态:AI编程、Compose与车载生态新信号
android·flutter
恋猫de小郭3 小时前
Dart 4.0 要彻底移除 dart:mirrors,Augmentations 应该要来了
android·前端·flutter
Carson带你学Android4 小时前
Gemini 4 Argon 发布:对 Android 开发者意味着什么?
android·ai编程
事圆则缓5 小时前
Kotlin Flow、StateFlow、SharedFlow 全解析:冷流、热流与 Android 状态管理
android·kotlin·php
应用市场5 小时前
把旧 Pixel 变成相册备份中转站(上):Mac 到安卓的照片传输工具设计——流式上传、sha256 校验、adb forward 与 Bonjour
android·macos·adb·kotlin·swift
墨天梦6 小时前
B08_Fragment事务通信与双生命周期
android
Kapaseker6 小时前
Android 以后可能不会再有横竖屏适配了
android·kotlin
墨天梦6 小时前
B13_通知图片相机与影音
android·数码相机·kotlin
事圆则缓7 小时前
Android 一次性事件怎么设计:Channel、SharedFlow 还是 UI State?
android·ui