I use FCM to notify where everything is working fine, but while the application is open, as soon as I kill (close) the application or in the background, I get a default notification if anyone can help me configure this notification when the application is closed ( or any other suggestion). Please help me with this, Thanks in Advance
Here is my code
@Override public void onMessageReceived(RemoteMessage remoteMessage) { String title = ""; if (remoteMessage.getNotification().getTitle() != null){ title = remoteMessage.getNotification().getTitle(); } String message = ""; if (remoteMessage.getNotification().getBody() != null){ message = remoteMessage.getNotification().getBody(); } Log.e("notification","recieved"); sendNotification(title, message); } private void sendNotification(String title, String message) { Intent intent = new Intent(this, MainActivity2.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); int color=getResources().getColor(R.color.dot_dark_screen2); NotificationCompat.Builder notifiBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.account_outline) .setColor(color) .setDefaults(Notification.DEFAULT_SOUND) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)) .setContentTitle(title) .setContentText(message) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setAutoCancel(true) .setSound(notificationSound) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 , notifiBuilder.build());

source share