Intent to resume a previously paused activity (Called from a Notification)

后端 未结 5 1503
自闭症患者
自闭症患者 2020-12-25 15:05

I\'m developing an app which shows a notification to the user. The notification\'s objective is to make it easy to the user to return to the activity when the user is in ano

5条回答
  •  醉话见心
    2020-12-25 15:31

    Apart from the correct answer of @Jimix I would change the PendingIntent requestCode from 0 to a non zero value as commented on another answer. On the other hand, there is a known bug on previous Android versions that took me a couple of desperate hours. The solution proposed there worked fine for me cancelling the PendingIntent before of sending the notification:

    if (Build.VERSION.SDK_INT == 19) {
       getNotificationPendingIntent().cancel();
    }
    

提交回复
热议问题