通过通知项重新打开后台应用程序 [英] re-open background application via notification item

查看:19
本文介绍了通过通知项重新打开后台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有标签和通知栏条目的应用程序,当我将其发送到后台时(单击主页按钮)并尝试通过单击重新打开应用程序通知栏,应用程序重新启动(上次选择标签丢失).

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).

当我按住主页按钮时,如果应用程序在背景并从那里选择它或单击应用程序在主屏幕上的图标,之前的状态是默认恢复(选择了正确的选项卡)

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 通知的意图是错误的,但我是不知道如何解决.

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?

谢谢!

推荐答案

把这两行.这将恢复当前暂停的活动:

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

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

这篇关于通过通知项重新打开后台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆