title: Android - Unit Testing that an activity has been started, and work on it
body: <p>I'm testing an object that's supposed to start a new activity when the open(url) method is called on it :</p>
  
  <pre><code>public void open(String url) {
      Intent i = new Intent(getContext(), Browser.class);
      Log.d(TAG, "open:" + url);
      i.putExtra("URL", url);
      i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      getContext().startActivity(i);
  }
  </code></pre>
  
  <p>I'd like to get the instance of the activity, and check some parameters based on the URL.</p>
  
  <p>I found this snipped :</p>
  
  <pre><code>ActivityManager am = (ActivityManager) mActivity
      .getSystemService("activity");
  List&lt;ActivityManager.RunningTaskInfo&gt; taskInfo = am.getRunningTasks(1);
  ComponentName componentInfo = taskInfo.get(0).topActivity;
  </code></pre>
  
  <p>but it only returns the name of the class, and I'd like to assert stuff on the instance of the activity.</p>
  
  <p>Has anybody an idea on how to do this?</p>
  
  <p>Thanks :-)</p>
  
  <p>Julien</p>