2

I don't want to start activity when user clicks on notification in status bar when activity A is showing, but when A has been destroyed or invisiable, activity has been start normally when user click a notification.

How can I do? Thanks!

Update, this is my code to show Notification:

Intent notificationIntent = new Intent(context, MainActivity.class);
    notificationIntent.putExtra(GCMReceiver.EXTRA_NOTIFICATION_MESSAGE,
            notiMessage);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
            this.context);      
    mBuilder.setContentText(message);

    mBuilder.setContentTitle(title);
    mBuilder.setAutoCancel(true).setSmallIcon(R.drawable.ic_notification)
            .setContentIntent(pendingIntent);       
    mNotificationManager.notify(KEY_PUSH_NOTIFICATION, mBuilder.build());
tungdx
  • 111
  • 2
  • 7

1 Answers1

0

You can init your pendingIntent like below for not opening class when user click on notification:

PendingIntent contentIntent = 
                PendingIntent.getActivity(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT); 

        builder.setContentIntent(contentIntent);  
Bhoomika Brahmbhatt
  • 7,404
  • 3
  • 29
  • 44