Android: How to resume an App from a Notification?

前端 未结 2 2008
后悔当初
后悔当初 2020-12-03 01:59

I am trying to program my notification to RESUME my app, instead of simply starting a new instance of my app... I am basically looking for it to do the same thing as when th

相关标签:
2条回答
  • 2020-12-03 02:07

    you need to set your flags

     notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;   
     notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    

    Also, if you never ever want there to be a duplicate activity give it this attribute in the manifest

    android:launchMode="singleTask"
    
    0 讨论(0)
  • 2020-12-03 02:08

    Selected answer didn't work for me, but if anyone else if viewing this, this did work for me: Resume application and stack from notification

    0 讨论(0)
提交回复
热议问题