Sending intent to BroadcastReceiver from adb

前端 未结 8 1744
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 20:26

I\'ve got BroadcastReceiver class:

public class IntentReceiver extends BroadcastReceiver {

    final String tag = \"Intent Intercepter\";

    @Override
            


        
相关标签:
8条回答
  • 2020-11-29 21:15

    You need not specify receiver. You can use adb instead.

    adb shell am broadcast -a com.whereismywifeserver.intent.TEST 
    --es sms_body "test from adb"
    

    For more arguments such as integer extras, see the documentation.

    0 讨论(0)
  • 2020-11-29 21:15

    Noting down my situation here may be useful to somebody,

    I have to send a custom intent with multiple intent extras to a broadcast receiver in Android P,

    The details are,

    Receiver name: com.hardian.testservice.TestBroadcastReceiver

    Intent action = "com.hardian.testservice.ADD_DATA"

    intent extras are,

    1. "text"="test msg",
    2. "source"= 1,

    Run the following in command line.

    adb shell "am broadcast -a com.hardian.testservice.ADD_DATA --es text 'test msg' --es source 1 -n com.hardian.testservice/.TestBroadcastReceiver"
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题