How can I pass an Extra to an Android intent using MonkeyRunner?

守給你的承諾、 提交于 2019-12-06 02:13:39

问题


I am trying to test my app using the MonkeyRunner tool. I am trying to add an EXTRA to my activity. The python script executes without error:

device = MonkeyRunner.waitForConnection()
device.wake()
extra = {'MY_EXTRA', True}
device.startActivity(component="org.mycompany.myapp/.activity.Show",extras=extra)

But when I inspect the intent in my app I do not get the value passed:

boolean myExtra = i.getBooleanExtra("MY_EXTRA", false);

What am I missing? Am I passing in the intent wrong? Am I inspecting the value in the Android app wrong?


回答1:


This is a bug in MonkeyRunner. It is not correctly handling passing boolean into extras. If you pass a string instead, it should work.

This fixes this issue.



来源:https://stackoverflow.com/questions/4891276/how-can-i-pass-an-extra-to-an-android-intent-using-monkeyrunner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!