Android

Android adb 模拟广播

2020-12-23  本文已影响0人  Erich_Godsen

adb shell am broadcast后面的参数有:

[-a <ACTION>]                                    //需要拦截的广播类型
[-d <DATA_URI>]
[-t <MIME_TYPE>] 
[-c <CATEGORY> [-c <CATEGORY>] ...] 
[-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]   //string类型
[--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]     //boolean类型
[-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]      //int类型
[-n <COMPONENT>]                                 //需要监听的广播类
[-f <FLAGS>] [<URI>]

例如:

adb shell am broadcast -a android.net.conn.CONNECTIVITY_CHANGE -n com.android.broadcast/com.android.broadcast.InstallReceiver --es test_string "this test" --ei test_int 10 --ez test_boolean true

但是针对json字符串的模拟需要按照下面格式来写

adb shell am broadcast -a "com.test.android.player" --es "data" '"''{"request":"playControl","requestParam":{"uuid":"123","controlType":"unlike"}}''"'
上一篇下一篇

猜你喜欢

热点阅读