title: Android GCM open app with data
body: <p>I want to open a different activity when a user opens the app by pressing on the Push Notification. </p>
  
  <p>This activity needs to be on top of the main. So when a user presses the Notification the stack should be:</p>
  
  <p>Activity A -> Activity B. </p>
  
  <p>Now i think their are 2 situations: </p>
  
  <ul>
  <li>The app is already running (so the main activity is already presented)</li>
  <li>The app is not running. (main activity is not presented)</li>
  </ul>
  
  <p>So my question: How should i open the app, showing a new activity, with the main activity in its stack.</p>
  
  <p>Code below only works when the app is already running (so the main activity is already in the stack).</p>
  
  <pre><code>    Intent notificationIntent = new Intent(this, ExtraActivity.class);
      notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
      notificationIntent.setAction(Intent.ACTION_MAIN);
  
      PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
  
      String appName = getResources().getString(R.string.app_name);
      int icon = R.drawable.ic_launcher;
  
      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
      .setSmallIcon(icon)
      .setContentTitle(appName)
      .setStyle(new NotificationCompat.BigTextStyle()
      .bigText(message))
      .setContentText(message);
  
      mBuilder.setContentIntent(pendingIntent);
  
      mNotificationManager.notify(uniqueId, mBuilder.build());
  </code></pre>