Last active
October 26, 2015 15:09
-
-
Save elevenetc/df58a6ee4b776edb67c2 to your computer and use it in GitHub Desktop.
Getting current activity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://qathread.blogspot.de/2014/09/discovering-espresso-for-android-how-to.html | |
//http://stackoverflow.com/questions/25998659/espresso-how-can-i-check-if-an-activity-is-launched-after-performing-a-certain | |
public Activity getActivityInstance(){ | |
getInstrumentation().runOnMainSync(new Runnable() { | |
public void run() { | |
Collection resumedActivities = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(RESUMED); | |
if (resumedActivities.iterator().hasNext()){ | |
currentActivity = resumedActivities.iterator().next(); | |
} | |
} | |
}); | |
return currentActivity; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment