Clicking on notification doesn't open mentioned activity

后端 未结 10 1176
感动是毒
感动是毒 2020-12-09 16:26

I am trying to open an Activity when the notification is clicked and below is my code.

Intent intent = new Intent(this.getApplicationContext(),         


        
10条回答
  •  被撕碎了的回忆
    2020-12-09 16:41

    You have to use FLAG_UPDATE_CURRENT in pendingIntent.

    PendingIntent pendingIntent = PendingIntent.getActivity(this, notificationId /* Request code */, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
    

    and also pass the same id to notificationManager

     notificationManager.notify(notificationId /* ID of notification */, notificationBuilder.build());
    

提交回复
热议问题