Notification starts Activity and restores the task stack

Do the download function, Notification opens the download list, the product requires click the back button at this time to restore to the previous one

HomeActivity, it is not difficult for participants, just add getActivities to PengingIntent

Pay attention to setting HomeActivity to singleTask to prevent the problem of repeatedly opening two HomeActivity

Known issue: On the download list page, clicking the notification bar to open DownloadListActivity will cause DownloadListActivity to restart

val intentHome = Intent(this, HomeActivity::class.java)
intentHome.flags = Intent.FLAG_ACTIVITY_NEW_TASK
val intent = Intent(this, DownloadListActivity::class.java)

val pi = PendingIntent.getActivities(this, 0, arrayOf(intentHome, intent), PendingIntent.FLAG_CANCEL_CURRENT)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324419182&siteId=291194637