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

2k views Asked by At

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

There are 1 answers

1
Bill On

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.