title: firebase notification not showing in snackbar while app closed android
body: <p>i want to show <strong>firebase push notification(sending firebase console) in activity's snackbar by broadcast</strong> receiver which i get from <strong>FirebaseMessagingService</strong> but i am unable to show.please help me.</p>
  
  <p>Manifest:</p>
  
  <pre><code>&lt;service android:name=".MyFirebaseMessagingService"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
  </code></pre>
  
  <p>firebase message service:</p>
  
  <pre><code>public class MyFirebaseMessagingService extends FirebaseMessagingService {
  
      @Override
      public void onMessageReceived(RemoteMessage remoteMessage) {
  
          if(remoteMessage.getData().size()&gt;0){
              Log.v("Message data", remoteMessage.getData().toString());
          }
  
          if(remoteMessage.getNotification()!=null){
              Log.v("MessageNotification", remoteMessage.getNotification().getBody().toString());
          }
  
          if(remoteMessage!=null){
              sendNotification(remoteMessage.toString());
          }
      }
  
      private void sendNotification(String messageBody){
  
          Intent intent=new Intent(this,NotificationShowActivity.class);
          intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          intent.putExtra("FireBaseNotification",messageBody);
          PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                  PendingIntent.FLAG_ONE_SHOT);
  
          Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
          NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                  .setSmallIcon(R.mipmap.notification_icon)
                  .setContentTitle("Notification")
                  .setContentText(messageBody)
                  .setAutoCancel(true)
                  .setSound(defaultSoundUri)
                  .setContentIntent(pendingIntent);
          NotificationManager notificationManager =
                  (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  
          notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
          LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
      }
  </code></pre>
  
  <p>notificationShow Activity:</p>
  
  <pre><code> @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_notification_show);
  
          linearLayout=(RelativeLayout)findViewById(R.id.activity_notification_show);
  
      }
  
  
      @Override
      protected void onPause() {
          super.onPause();
          unregisterReceiver(broadcastReceiver);
      }
  
      @Override
      protected void onStop() {
          super.onStop();
      }
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
      }
  
      @Override
      protected void onResume() {
          super.onResume();
  
          registerReceiver(broadcastReceiver,new IntentFilter(MyFirebaseMessagingService.NOTIFICATION_SERVICE));
  
      }
  
      //broadcastReceiver
  
      private BroadcastReceiver broadcastReceiver=new BroadcastReceiver() {
          @Override
  
          public void onReceive(Context context, Intent intent) {
  
              String message=intent.getStringExtra("FireBaseNotification");
              if(message!=null){
  
                  Toast.makeText(NotificationShowActivity.this,message,Toast.LENGTH_LONG).show();
  
              }
          }
      };
  
  }
  </code></pre>