Buen dia, tengo un problema con las notificaciones de Firebase, y AndroidStudio y es que la notificacion, "cuando la app esta abierta y le doy click", no hace nada, solo me manda a la pantalla principal de login de la app. si la aplicacion esta cerrada o en segundo plano al darle click si realiza la accion que en este caso es abrir una actividad y pasarle extras, pero si la app esta abierta y le doy click a la notificacion, esta no hace nada, quiero hacer que cuando la app este abierta y llegue la NOTIFICACION, haga lo mismo que cuando le doy click y la app esta cerrada
@Override
public void onMessageReceived(@NonNull RemoteMessage message) {
super.onMessageReceived(message);
String mensaje = message.getFrom();
Log.e("tokenf", "msg"+mensaje);
notiTitle=message.getData().get("Title");
mayorOreo(message.getData().get("Title"), message.getData().get("Detalle"));
}
private void mayorOreo(String titulo, String detalle){
Uri soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE+ "://" + getPackageName() +"/" + R.raw.song);
String id= "mensaje";
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder buldier = new NotificationCompat.Builder(this,id);
NotificationChannel nc = new NotificationChannel(id, "nuevo", NotificationManager.IMPORTANCE_HIGH);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_ALARM)
.build();
//personalizamos la notificacion
nc.setSound(soundUri, audioAttributes);
nc.setShowBadge(true);
nm.createNotificationChannel(nc);
buldier.setAutoCancel(true).setWhen(System.currentTimeMillis()).
setContentTitle(titulo).setSmallIcon(R.mipmap.ic_launcher).
setContentText(detalle).
setSound(soundUri).
setContentIntent(clickNoty())
.setContentInfo("Nuevo");
Random random = new Random();
int notifyId = random.nextInt(9000);
assert nm!=null;
nm.notify(notifyId, buldier.build());
}
public PendingIntent clickNoty(){
Intent iNoti = new Intent(this,DetalleAlerta.class);
String part[] = notiTitle.split(": ");
iNoti.putExtra("notiIncidenteId",part[1]);
iNoti.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
return PendingIntent.getActivity(this,0, iNoti,PendingIntent.FLAG_MUTABLE| PendingIntent.FLAG_UPDATE_CURRENT);
}
}