How to set click listener for notification?

后端 未结 3 1076
别那么骄傲
别那么骄傲 2020-12-01 09:06

I am using the following code to launch a notification when a Service is started Via AlarmManager:

nm = (NotificationManager) this.getSystemService(Context.N         


        
3条回答
  •  天命终不由人
    2020-12-01 10:03

    You basically need to put the Activity class as part of your intent into your PendingIntent. Currently your Intent is empty. To redirect to new activity, it should be:

    // This line of yours should contain the activity that you want to launch. 
    // You are currently just passing empty new Intent()
    PendingIntent contentIntent = 
        PendingIntent.getActivity(this, 0, new Intent(this, MyActivity.class), 0);
    

提交回复
热议问题