title: Programmatically click on Android notification
body: <p>I am black-box testing an application by using the <a href="http://code.google.com/p/robotium/" rel="noreferrer">Robotium framework</a>.
  The app under test send a notification in the status bar each time I install a new application.
  I would like to click on that notification, but I still did not find a proper way to do it.</p>
  
  <p>When I manually click on one notification I get this <code>logcat</code> lines:</p>
  
  <pre><code>I/ActivityManager(  148): START {flg=0x14000000 cmp=com.test.package/.activity.FrontActivity bnds=[0,38][240,86] (has extras) u=0} from pid -1
  I/ActivityManager(  148): START {flg=0x14000000 cmp=com.test.package/.activity.ResultActivity u=0} from pid 8600
  I/ActivityManager(  148): Displayed com.test.package/.activity.FrontActivity: +1s183ms
  I/ActivityManager(  148): Displayed com.test.package/.activity.ResultActivity: +744ms
  </code></pre>
  
  <p>I know Robotium cannot test 2 different applications at the same time, as well as I know you can't get the notification of an external application.</p>
  
  <p>I also tried to get the pending intent and fire it up by using the following code:</p>
  
  <pre><code>Context context = this.getInstrumentation().getTargetContext().getApplicationContext();
  String intentClassString = "com.test.package.activity.FrontActivity";
  Class&lt;?&gt; intentClass = null;
  
  try {
      intentClass = Class.forName(intentClassString);
  } catch (ClassNotFoundException e) {
      e.printStackTrace();
  }
  
  Intent intent = new Intent(context, intentClass);
  PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_NO_CREATE);
  
  try {
      pendingIntent.send();
  } catch (CanceledException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>The activity is actually showed, but it is different from what I obtain by manually invoking it. I think something is wrong in the context I pass, or the way I call the pending intent.</p>
  
  <p>Any hint about this issue? Is there a better way to simulate the click on a notification?</p>