重新打开通过项目的通知后台应用后台、通知、项目

2023-09-04 07:32:23 作者:除膜慰道

我有一个应用程序有标签和通知栏条目, 当我将其发送到后台(点击home键) 并试图通过点击重新打开应用程序 通知栏,应用程序重新启动(最后选定 选项​​卡丢失)。

I got an app with tabs and a notification bar entry, when I send it to background (click on home button) and try to re-open the application via click on the notification bar, the app restarts (last selected tab is lost).

当我按住home键,如果应用程序在 背景并从那里选择它,或者单击 应用程序的主屏幕上的图标,previous状态 每默认恢复(正确的选项卡中选择)

When I hold the home button if the application is in the background and select it from there or click the app's icon on the homescreen, the previous state is restored per default (the correct tab is selected)

国际海事组织通报的目的是错误的,但我 不知道如何解决它。

IMO the intent of the notification is wrong, but I'm not sure how to fix it.

简而言之:如何获得一个后台应用回 前台当我点击该通知条目?

In short: How to get a background application back to foreground when I click the notification entry?

THX!

推荐答案

把这两行。这将恢复目前已暂停活动:

Put these two lines. This will resume currently paused activity:

notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);