使用控制台通过捆绑发送意图 [英] Sending intent with bundle using console

查看:32
本文介绍了使用控制台通过捆绑发送意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Android 应用,用于侦听包含一些数据包的特定意图.我想使用 adb 向我的应用程序发送一个意图.我试过:

I'm developing an Android app listening for specific intent containing a bundle with some data. I would like to send an intent to my app using adb. I have tried with:

adb shell am startservice -a com.INTENT_NAME -e myBundleName myBundleData com.pkg/com.pkg.cls

但我的应用程序将其识别为字符串列表而不是捆绑包.有谁知道如何使用 am 应用程序通过捆绑发送意图?不幸的是,文档只说明了发送字符串或数字列表,而没有说明捆绑.

but my app recognised it as list of string not as a bundle. Does anyone know how to send intent with bundles using am application? Unfortunately documentation says only about sending lists of string or numbers, nothing about bundle.

推荐答案

根据源代码 am 无法接受bundle 输入

According to the source code am has no way of accepting input data of the bundle type

更新:在 Android 7.0 中,意图参数解析代码 已从 移动href="https://android.googlesource.com/platform/frameworks/base/+/android-10.0.0_r1/core/java/android/content/Intent.java#7042" rel="nofollow noreferrer">我.java 到 Intent.java 并添加了对更多数据类型(如基本类型的Array[]ArrayList<>)的支持.不幸的是,仍然不支持 am 命令中的 Bundle 类型附加项.

Update: In Android 7.0 the intent parameters parsing code has been moved from Am.java to Intent.java and support for more data types (like Array[] and ArrayList<> of basic types) has been added. Unfortunately there is still no support for the Bundle type extras in am command.

这篇关于使用控制台通过捆绑发送意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆