I am working on an app that uses notifications, the notification appears, but the app doesn't open when I tap it.
The app should open upon the following three condition.
If the app is already open then upon clicking the notification, it should be removed from status bar.
If app is in background and if we click on the notification, the app should resume with whatever screen was open previously.
If app close and the notification is clicked, app should start.
please any one help me, I am struggling on this from last two days.
There following is the code that I am using:
Intent resultIntent = new Intent(this, MapActivity.class);
NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
notiStyle.setBigContentTitle(team);
notiStyle.bigText(message);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);
return new NotificationCompat.Builder(this).setSmallIcon(icon)
.setAutoCancel(true)
.setContentIntent(resultPendingIntent).setContentTitle(team)
.setContentText(message).setStyle(notiStyle).build();