title: FCM Notification onclick does not open desired activity
body: <p>i have tried almost every solution posted here and combination of every flag but it is not working.</p>
  
  <p>Following are use cases in which i am having problems.</p>
  
  <p>1) When i am in application <strong>FCM</strong> notification opens my desired activity.
  Data is passed to <code>onNewIntent</code> in main activity. It works fine when application is foreground.</p>
  
  <p>2) When in background mode(presssing home button) after clicking on notification it launches new instance of my application even though i have specified <code>android:launchMode="singleTop"</code> in manifest file to my main activity but i don't know what is happening here. Desired Activity i want to open here is <strong><code>RateEventActivity</code></strong></p>
  
  <p>the strange thing happening here is that <code>NotificationActivity</code> and  <code>ProfileActivity</code> are working perfectly even when application is in background mode but <strong><code>RateEventActivity</code></strong> is producing all the problem as i described above. Most of application code is written by someone else  i am working on <code>RateEevent</code> module so i don't know what i am missing here?</p>
  
  <p>Intents are lost somewhere (not passed to <code>mainActivty</code> on create) when i am clicking notification from background mode in <strong><code>RateEventActivity</code></strong> scenario. </p>
  
  <p>i have also tried passing unique id to my pending intent but no luck. I have put lot of time and effort to solve this but failing every time</p>
  
  <p><strong>here is my FCM code</strong></p>
  
  <pre><code>  private void createNotification(RemoteMessage remoteMessage) {
      RemoteMessage.Notification notification = remoteMessage.getNotification();
      NotificationManager mNotificationManager = (NotificationManager)
              this.getSystemService(Context.NOTIFICATION_SERVICE);
  
      Log.v("Notification Title", remoteMessage.getNotification().getTitle());
  
      Intent intent = new Intent(this, MainActivity.class);
      //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
      if (remoteMessage.getData().containsKey("notificationUser")) {
          intent.putExtra("notificationUser", remoteMessage.getData().get("notificationUser"));
      } else if (remoteMessage.getData().containsKey("notificationId")) {
          intent.putExtra("notificationId", remoteMessage.getData().get("notificationId"));
      } else if (remoteMessage.getData().containsKey("event")) {
          if (remoteMessage.getNotification().getTitle().equalsIgnoreCase("Event Feedback")) {
  
  
              Log.v("Notification Event", remoteMessage.getData().get("event"));
              intent.putExtra("eventId", remoteMessage.getData().get("event"));
          }
  
  
      }
  
  
      //PendingIntent.FLAG_UPDATE_CURRENT
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0 , intent,
              PendingIntent.FLAG_UPDATE_CURRENT);
  
      Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
  
      NotificationCompat.Builder mBuilder =
              new NotificationCompat.Builder(this)
                      .setSmallIcon(R.drawable.ic_notification)
                      .setLargeIcon(largeIcon)
                      .setContentTitle(notification.getTitle())
                      .setStyle(new NotificationCompat.BigTextStyle()
                              .bigText(notification.getBody()))
                      .setContentText(notification.getBody())
                      .setAutoCancel(true);
  
      mBuilder.setContentIntent(contentIntent);
      mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
  }
  </code></pre>
  
  <p>Main Activity Code <code>onCreate</code> Method</p>
  
  <pre><code>   if (getIntent().hasExtra("notificationId")) {
          Intent intent = new Intent(this, NotificationActivity.class);
          intent.putExtra("notificationId", getIntent().getStringExtra("notificationId"));
          startActivity(intent);
      } else if (getIntent().hasExtra("user")) {
          Intent intent = new Intent(this, ProfileActivity.class);
          intent.putExtra("userId", getIntent().getStringExtra("user"));
          startActivity(intent);
      } else if (getIntent().hasExtra("eventId")) {
          Intent intent = new Intent(this, RateEventActivity.class);
          intent.putExtra("eventId", getIntent().getStringExtra("eventId"));
          startActivity(intent);
      }
  </code></pre>
  
  <p><strong>My Manifest File</strong></p>
  
  <pre><code> &lt;activity
          android:name=".activities.MainActivity"
          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:launchMode="singleTop"
          android:screenOrientation="portrait"
          android:theme="@style/HomeTheme" /&gt;
  
  &lt;activity
          android:name=".activities.ProfileActivity"
          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:label="Profile"
          android:screenOrientation="portrait" /&gt;
  
   &lt;activity
          android:name=".activities.NotificationActivity"
          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:label="Notifications"
          android:screenOrientation="portrait" /&gt;
  
  &lt;activity
          android:name=".activities.RateEventActivity"
          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:label="Rate Users"
          android:screenOrientation="portrait"
         /&gt;
  </code></pre>