从 Monkeyrunner 传递带有 Parcelable 对象的 Bundle
在 Monkeyrunner 中启动活动时,我试图在我的 extra 中传递一个 Parcelable 对象。脚本中的区域看起来像这个
user = FbUser()
extraDic = {}
extraDic['userName'] = 'Test'
extraDic['userId'] = 'me'
extraDic['userInfo'] = user
d.startActivity(extras=extraDic, component=runComponent + postActivity)
FbUser 是我的 java 项目中实现 Parcelable 的对象。项目的 bin 已正确添加到 Jython Monkeyrunner 脚本中的 sys.path 中。当我调试脚本时,它正确地创建了 FbUser 对象,但是,当我在 LogCat 中打印出额外内容时,缺少“userInfo”额外内容...这似乎是因为类 JythonUtils 只会转换 PyString、PyFloat 和 PyInteger即使 MonkeyDevice 的文档声明您可以在 extras 字典中传递任何结构化数据类型,也可以将其转换为 String、Double 和 Integer。有没有人找到办法做到这一点?
I'm trying to pass a Parcelable object in my extras when starting an activity in Monkeyrunner. The area in the script looks like this
user = FbUser()
extraDic = {}
extraDic['userName'] = 'Test'
extraDic['userId'] = 'me'
extraDic['userInfo'] = user
d.startActivity(extras=extraDic, component=runComponent + postActivity)
FbUser is the object in my java project that implements Parcelable. The bin of the project has been properly added to the sys.path in the Jython Monkeyrunner script. When I debug the script, it creates the FbUser object correctly, however, when I print out the extras in LogCat, the 'userInfo' extra is missing... This appears to be because the class JythonUtils will only translate PyString, PyFloat and PyInteger to String, Double and Integer even though the documentation for MonkeyDevice states you can pass any structured data type in the extras dictionary. Has anyone found a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近才遇到这个问题,并阅读了源代码,发现不幸的是这是不可能的。
MonkeyDevice 实例将其工作委托给 am 命令由 adb - 执行。您可能已经知道, am 能够从命令行接受的额外内容是 相当有限。事实上,它可以携带字符串、布尔值或整数。
I've come into that problem just recently and read the source to find out that unfortunately this is not possible.
MonkeyDevice instance delegates its work to am command by adb -. As you may already know, the extras that am is able to accept from command line is quite limited. In fact it can carry a String, a boolean or an int.