title: Why onMessageReceived() method is not passing intent properly when the app is in background?
body: <p>Actually I'm trying to pass intent to an <code>activity</code> on click of the <code>push-notification</code> and it's working fine when the app is present in <code>foreground</code>.But when the app is in background although I'm receiving the <code>push-notification</code> without any problem but by clicking that notification I'm not getting intent in the <code>activity</code>. I tried to refer some questions in <code>SO</code> and tried adding flags like<code>PendingIntent.FLAG_UPDATE_CURRENT</code>,
  <code>PendingIntent.FLAG_ONE_SHOT</code>,then in intent <code>(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP )</code> but none of them were helpful . Please help me to solve this issue it's been a pain in the neck from last two days.</p>
  
  <p><strong>Manifest.XML:</strong></p>
  
  <pre><code>&lt;activity android:name=".activities.ProfileHolder"
          android:windowSoftInputMode="adjustPan"
          android:screenOrientation="portrait"
          android:exported="true"
          android:launchMode="singleTop"
         &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="profile" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p><strong>Notification Code in Node.js:</strong></p>
  
  <pre><code>var message = {
           to: u.fcm_token, 
           collapse_key: 'white', //anything can be given
           data: {
               type:"likes",
               post_owner_username:data.like_post_owner_username,
               owner_post_time:data.like_post_owner_time
  
           },
           priority: 'high',
           notification: {
               title: 'Infinity',
               body:notif_data,
               sound: "default",
               click_action: "profile",
               tag:"Hey Bro" //if specified then current msg would be  replaced by new msg
           }
       };
  
       fcm.send(message, function(err, response){
           if (err) {
               console.log(err);
           } else {
               console.log("Successfully sent with response: ", response);
           }
       });
  </code></pre>
  
  <p><strong>FirebaseMessagingService Class :</strong></p>
  
  <pre><code>/Varibales for notifications
  String title, body, post_owner_username, post_owner_time, notif_commenter_username, notif_comment_time, follower_username,messager_username,type,action;
  @Override
  public void onMessageReceived(final RemoteMessage remoteMessage) {
      title=remoteMessage.getNotification().getTitle();
      body=remoteMessage.getNotification().getBody();
      type=remoteMessage.getData().get("type");
      action=remoteMessage.getNotification().getClickAction();
  
      Log.d("type",type);
      Log.d("type-2",title);
  
     if(type.equals("likes")){
         post_owner_username=remoteMessage.getData().get("post_owner_username");
         post_owner_time=remoteMessage.getData().get("owner_post_time");
     }
     else if(type.equals("comments")||type.equals("comment_likes")){
         post_owner_username=remoteMessage.getData().get("post_owner_username");
         post_owner_time=remoteMessage.getData().get("owner_post_time");
         notif_commenter_username=remoteMessage.getData().get("commenter_username");
         notif_comment_time=remoteMessage.getData().get("comment_time");
     }
     else if(type.equals("follow")){
         follower_username=remoteMessage.getData().get("follower_username");
     }
     else if(type.equals("messaging")){
         messager_username=remoteMessage.getData().get("sender_username");
     }
  
      //Showing Notification
  
      NotificationCompat.Builder mBuilder =
              new NotificationCompat.Builder(getApplicationContext(), Constants.CHANNEL_ID)
                      .setSmallIcon(R.drawable.new_icon)
                      .setContentTitle(title)
                      .setContentText(body);
  
      Intent i = new Intent(action);
      Bundle b = new Bundle();
      if (type.equals("likes")) {
          b.putString("post_owner_username", post_owner_username);
          b.putString("post_owner_time", post_owner_time);
          b.putString("what", "show_notification_post");
          b.putString("Open","starred");
  
          // i.putExtra("Open", "starred");
      }
      else if (type.equals("comments")) {
          b.putString("post_owner_username",post_owner_username);
          b.putString("post_owner_time", post_owner_time);
          b.putString("notif_commenter_username", notif_commenter_username);
          b.putString("notif_comment_time",notif_comment_time);
          b.putString("what", "show_notification_post");
          b.putString("Open","starred");
          //i.putExtra("Open", "starred");
      }
      else if (type.equals("comment_likes")) {
  
          b.putString("post_owner_username", post_owner_username);
          b.putString("post_owner_time", post_owner_time);
          b.putString("notif_commenter_username", notif_commenter_username);
          b.putString("notif_comment_time", notif_comment_time);
          b.putString("what", "show_notification_post");
          b.putString("Open","starred");
          // i.putExtra("Open", "starred");
      }
      else if (type.equals("follow")||type.equals("follow_request")) {
          b.putString("searchUsername", follower_username);
          b.putString("Open","search_profile");
          //i.putExtra("Open", "search_profile");
      }
      else if(type.equals("messaging")){
          b.putString("Open","messaging");
          b.putString("msg_username",messager_username);
      }
  
      i.putExtras(b);
      i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP );
      //ctx.startActivity(i);
      PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, i, PendingIntent.FLAG_UPDATE_CURRENT);
  
      /*
       *  Setting the pending intent to notification builder
       * */
  
      mBuilder.setContentIntent(pendingIntent);
  
      NotificationManager mNotifyMgr =
              (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  
  
      if (mNotifyMgr != null) {
          mBuilder.setAutoCancel(true);
          mNotifyMgr.notify(1, mBuilder.build());
      }
  }
  </code></pre>