Notification Click not launch the given Activity on Nexus Phones

后端 未结 9 922
一个人的身影
一个人的身影 2020-12-08 14:59

I am using this code to show the local notification and When notification comes then on click of notification want to launch the ListActivity but on Google nexus device

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 15:52

    I hope it will help u.

    long uniqueId= System.currentTimeMillis();

        /** This is the part to let your application recognise difference notification when the user click on the notification.
         *  You could use any unique string to represent your notification. But be sure each notification have difference action name.
         **/
        taskDetailIntent.setAction("notifi" + uniqueId);
    
    
        PendingIntent contentIntent = PendingIntent.
                getActivity(this, 0, taskDetailIntent, PendingIntent.FLAG_ONE_SHOT);
    
        builder.setContentIntent(contentIntent);
    
        /** Set the unique id to let Notification Manager knows this is a another notification instead of same notification.
         *  If you use the same uniqueId for each notification, the Notification Manager will assume that is same notification
         *  and would replace the previous notification. **/
        notificationManager.notify((int) uniqueId, builder.build());
    

提交回复
热议问题