Clicking on notification doesn't open mentioned activity

后端 未结 10 1169
感动是毒
感动是毒 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:50

    Set your pending intent like below

    Intent intent = new Intent(this.getApplicationContext(), NotificationActivity.class);
    intent.putExtra("msgBody",messageBody);
    intent.putExtra(Constants.NOTIF_INTENT_TYPE,Constants.NOTIF_INTENT_TYPE);
    
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
    

    add it to your notification using

    .setContentIntent(pendingIntent);
    

提交回复
热议问题