My Firebasemessagingservice class code for passing intent:
private void showNotification(String message){
Intent intent=new Intent(this, DrawerActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("data", message);
PendingIntent pendingIntent=PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder=new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("Registry")
.setContentText(message)
.setSmallIcon(R.drawable.com_facebook_button_send_icon_blue)
.setContentIntent(pendingIntent);
NotificationManager manager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(0,builder.build());
}
My Fragment BaseActivity code in onCreate() method:
Intent notifyIntent = getIntent();
Bundle extras = notifyIntent.getExtras();
if (extras != null) {
replacefragment code;
}
It's not working..
You need to send a key with intent data and check with that key and perform code like
and chech on Activity like
also check onIntent change fro if activity is already open
First, in the code were you make the notification declarate the intent at the next way:
Assign the intent to mBuilder
Then go to the activity main and add this code in the onCreate method:
Finaly add this method in MainActivity: