title: Using Robotium with intents
body: <p>I have an application with several activities with list views, the selection from the first list view determines the content of the second list view, and the second list view determines the contents of the third, etc.</p>
  
  <p>I want to test the third list view, but as it requires an intent the list returns nothing. To remedy this I can manually add the intent to the test which does mean it works</p>
  
  <pre><code>public InspectionListActivityTest() {
      super(InspectionListActivity.class);
      Intent i = new Intent();
      i.putExtra("guid", "abcbbf2b-5e14-4cb1-af1b-e3084b45d4cf");
      setActivityIntent(i);
  }
  </code></pre>
  
  <p>As you can see from the code, it uses guids to determine the list which is what I want to avoid - I clear the database a lot while I'm testing so I have to change this field all of the time. </p>
  
  <p>Ideally I want to use a ContentResolver to get the first guid from another table which would then mean I would be able to always pull back information in my tests, ie</p>
  
  <pre><code>public InspectionListActivityTest() {
      super(InspectionListActivity.class);
  
      ContentResolver cr = getActivity().getContentResolver();
      Cursor cursor = cr.query(Locations.CONTENT_URI, null, null, null, null);
      if (cursor != null) {
          if (cursor.moveToFirst()) {
              String guid = cursor.getString(cursor.getColumnIndex(Locations.GUID));
              Intent i = new Intent();
              i.putExtra(IntentFilters.LOCATION.getIntent(), guid);
              setActivityIntent(i);
          }
      }
  }
  </code></pre>
  
  <p>However, I get a nullpointerexception on the getActivity() method, and I don't seem to be able to put this setActivityIntent anywhere else.</p>