I want to open from a notification the acitivity main and another depending on a parameter but I can only open the main one and when receiving notifications with the open app this closes the code is as follows.
private void enviarNotificacion(RemoteMessage.Notification messageBody) {
Intent intent;
Notification notificacion;
if(messageBody.getClickAction().compareTo(null)==0){
intent = new Intent(getApplicationContext(),MainActivity.class);
}else{
intent = new Intent(getApplicationContext(),MostrarWeb.class);
}
PendingIntent pendingIntent =
PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
Uri defaultSoundUri=
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificacion = new NotificationCompat.Builder(this)
.setSmallIcon(getResources().getIdentifier(messageBody.getIcon(),
"drawable", getApplicationContext().getPackageName()))
.setLargeIcon(BitmapFactory.decodeResource(getResources(),
R.drawable.ic_noti))
.setContentTitle(messageBody.getTitle())
.setContentText(messageBody.getBody())
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
.build();
NotificationManager notificationManager =
(NotificationManager)
getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificacion);}