Skip to content

Commit

Permalink
Check if ActivityMonitor is null before calling waitForActivityWithTi…
Browse files Browse the repository at this point in the history
…meout
  • Loading branch information
renas committed Feb 3, 2016
1 parent 9c25822 commit bf4b6be
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions robotium-solo/src/main/java/com/robotium/solo/ActivityUtils.java
Expand Up @@ -142,21 +142,22 @@ private void setupActivityStackListener() {
if(activityMonitor == null){
return;
}

setRegisterActivities(true);

Runnable runnable = new Runnable() {
public void run() {
while (shouldRegisterActivities()) {

Activity activity = activityMonitor.waitForActivityWithTimeout(2000);

if(activity != null){
if (activitiesStoredInActivityStack.remove(activity.toString())){
removeActivityFromStack(activity);
}
if(!activity.isFinishing()){
addActivityToStack(activity);
if(activityMonitor != null){
Activity activity = activityMonitor.waitForActivityWithTimeout(2000);

if(activity != null){
if (activitiesStoredInActivityStack.remove(activity.toString())){
removeActivityFromStack(activity);
}
if(!activity.isFinishing()){
addActivityToStack(activity);
}
}
}
}
Expand Down

0 comments on commit bf4b6be

Please sign in to comment.