在亚行通过在Android广播发送JSON作为额外的数据得到格式不正确不正确、格式、数据、Android

2023-09-06 03:20:31 作者:默陌

我试图JSON数据发送给作​​为额外的在Android广播至极我通过亚行发送到设备。但它看起来像它获取到未如预期的设备中的数据。

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

我执行:

adb shell am broadcast -a com.test.android.ACTION_TEST_FEATURE -n com.test.android/.receivers.TestsReceiver -e "notify" '{"debug": false, "title": "Application update!"}'

我希望为额外的数据:

What I expect as extra data:

{"debug": false, "title": "Application update!"}

我所得到的额外数据:

What I get as extra data:

"debug": false

如果我把 {调试:虚假头衔:应用程序更新} 作为额外的数据,然后我得到 {调试:虚假头衔:应用程序更新} 作为额外的数据(注意缺少的逗号)。所以,我认为它是与括号扩展我的bash的,但关闭它并没有解决问题,逃避括号或逗号不能正常工作。

If I send {"debug": false "title": "Application update!"} as extra data then i get {"debug": false "title": "Application update!"} as extra data (noting the missing comma). So i assume it has something to do with Brace Expansion of my bash, but turning it off does not solve the problem and escaping the braces or the comma is not working.

是否有人有线索我究竟做错了什么?

Does anybody has a clue what am I doing wrong?

推荐答案

好吧,我只是找到了解决办法。我首先要进入设备外壳通过亚行外壳键,然后执行 AM广播-a -n com.test.android.ACTION_TEST_FEATURE com.test。安卓/ .receivers.TestsReceiver --es通知{调试:假的,称号:应用程序更新!}

ok, I just found a solution. I first have to enter the devices shell via adb shell and then execute am broadcast -a com.test.android.ACTION_TEST_FEATURE -n com.test.android/.receivers.TestsReceiver --es "notify" '{"debug": false, "title": "Application update!"}'

 
精彩推荐
图片推荐