使用adb shell am broadcast 发送广播

一、adb shell 发送广播举例

adb shell am broadcast -a com.action.test -f 0x01000000 --es "key1" "value1"
等价于:
Intent intent = new Intent();
intent.setAction("com.action.test");
intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
intent.putExtra("key1","value1");
sendBroadcast(intent);
二、参数说明
其中extra_key表示键,extra_string_value表示值。
其他命令解释:
三、应用
adb 发广播,通过广播,更改某些配置信息。
例如:adb发送广播消息后,接收到该广播时,更改sharedpreferences配置;更改日志标识,开启debug日志打印;

发表回复

后才能评论