adb shell am broadcast 发送广播
一、adb shell 发送广播举例adb shell am broadcast -a com.action.test -f 0x01000000 --es “key01” “value01”等价于:Intent intent = new Intent();intent.setAction("android.test");intent.addFlags(Intent.FLAG_RECEIVER_I
·
一、adb shell 发送广播举例
adb shell am broadcast -a com.action.test -f 0x01000000 --es “key01” “value01”
等价于:
Intent intent = new Intent();
intent.setAction("android.test");
intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
intent.putExtra("key01","value01");
sendBroadcast(intent);
二、参数说明
参数 | 描述 |
---|---|
-a action | 指定intent操作,如android.intent.action.VIEW。 |
-f flags | 向setFlags()支持的intent添加标记。如FLAG_RECEIVER_INCLUDE_BACKGROUND:0x01000000 |
–es extra_key extra_string_value | 以键值对的形式添加字符串数据。 |
–ez extra_key extra_boolean_value | 以键值对的形式添加布尔值数据。 |
–ei extra_key extra_int_value | 以键值对的形式添加整数型数据。 |
–el extra_key extra_long_value | 以键值对的形式添加长整型数据。 |
–ef extra_key extra_float_value | 以键值对的形式添加浮点型数据。 |
参考:
参考Android 调试桥 (adb):
https://developer.android.com/studio/command-line/adb?hl=zh-cn#IntentSpec
三、应用
- adb 发广播
- 通过广播,更改某些配置信息。
例如:
adb发送广播消息后,接收到该广播时,更改sharedpreferences配置;更改日志标识,开启debug日志打印;
更多推荐
所有评论(0)