Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I get current activity with Robolectric?

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?

like image 576
kaneda Avatar asked Aug 30 '11 20:08

kaneda


1 Answers

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();
like image 191
Giorgos Kylafas Avatar answered Nov 05 '22 04:11

Giorgos Kylafas