Suppose I have an activity A that launches another activity B from within its onCreate()
method, expecting for results.
How do I get activity B using Robolectric?
How about this:
ActivityA activityA = setupActivity(ActivityA.class);
// Start other activity by e.g. pushing on a button
Intent intentForB = shadowOf(activityA).peekNextStartedActivity();
ActivityB activityB = buildActivity(ActivityB.class).withIntent(intentForB)
.create().get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With