title: Android: Launch an external app from notification
body: <p>I am trying to create a notification that when clicked will open an external app. I've seen the documentation for <a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CreateNotification" rel="nofollow">creating notifications</a> and for <a href="http://developer.android.com/training/basics/intents/sending.html" rel="nofollow">sending the user to another app</a>. But I can't seem to figure out how to combine the two. The problem is that the advised way to launch an app from a notification, is to creating the <em>pending intent</em> like this:</p>
  
  <pre><code>Intent intent = new Intent(this, MyActivity.class);
  TaskStackBuilder stackBuidler = TaskStackBuilder.create(context);
  stackBuilder.addParentStack(MyActivity.class); 
  stackBuilder.addNextIntent(intent);
  PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
  </code></pre>
  
  <p>But to launch an external app, you have to create an <em>implicit intent</em> like this:</p>
  
  <pre><code>String uri = ...
  Intent intent = new Intent(Intent.ACTION_VIEW, uri);
  </code></pre>
  
  <p>As far as I can tell, there is no way to create the TaskStackBuilder with this kind of intent, because <code>addParentStack()</code> will only take an <code>Activity</code>, a <code>Class</code>, or a <code>ComponentName</code>. </p>
  
  <p>I guess the question boils down to... is it possible to create a intent that is both pending and implicit? </p>
  
  <p>The only workaround I can think of right now is to create an Activity in my app that does nothing but launch the external app. </p>
  
  <p>I did try creating the intent from the URI then doing the following, but nothing happens when you click the notification:</p>
  
  <pre><code>PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  </code></pre>