Sending JSON as extra data in an android broadcast via ADB gets incorrectly formatted

前端 未结 4 676
暖寄归人
暖寄归人 2021-01-04 07:42

I\'m trying to send JSON data as extra on an Android broadcast which I send via ADB to the device. But it looks like the data which gets to the device is not as expected.

4条回答
  •  爱一瞬间的悲伤
    2021-01-04 08:01

    This should be the structure of the adb command.

    adb shell "am broadcast -a YOUR_BROADCAST_INTENT_ACTION -n YOUR_APP_PACKAGE/.PATH_TO_BROADCAST_RECIEVER_CLASS.BROADCAST_RECEIVER_CLASS -e 'STRING_KEY' 'DATA HERE'"
    

    The above command will ensure delivery of the intent to the receiver even if the string has spaces in it.

    adb shell "am broadcast -a wingoku.custom.invoking.event -n com.wingoku.root/.broadcastReceivers.MyReceiver-e 'shellCommand' 'hello world. My name is umer'"
    

提交回复
热议问题