我有一个关于Android任务和意图管理的问题。
场景
问题:
从历史上启动应用程序(长按主键或多任务处理按钮)不会重置任务(从应用图标启动时会这样做)。
我明白,从历史上启动一个应用程序不应该重置任务,因为它被用来作为“回到原样”。然而,在我的例子中,这是一个问题,因为从通知启动应用程序是一次性的事情。
还有人遇到过这个问题吗?有人知道解决办法吗?
更深入的
PendingIntent内部的意图是这样构建的:
Intent intent = new Intent (Intent.ActionView);
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.setData (Uri.Parse (DEEP_LINK_URL));就在这一天,我发现了FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,我真的以为它能解决我的问题,但没有什么区别。
有三项值得关注的活动:
SplashActivity (main launcher & listener of the deep-linking schema -- this activity just redirects either to login or OverviewActivity)
OverviewActivity (authorized user's main activity)
Feature1Activity (any feature that the deep-link is pointing to)当用户单击通知时所发生的情况是,SplashActivity充当模式的侦听器,并将深度链接url转换为两个意图,以使用Activity.startActivities (Intent[])启动OverviewActivity和Feature1Activity。
当我查看SplashActivity内部通知的意图时,它总是包含数据中的深层链接。
One围绕着工作
这里有一项工作,将一些booleanExtra字段设置为通知意图(例如"ignoreWhenLaunchedFromHistory“= true),然后在重定向之前签入SplashActivity
boolean fromHistory = (getIntent().getFlags() & FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY;
if (fromHistory && getIntent().getBooleanExtra ("ignoreWhenLaunchedFromHistory", false))
// Don't follow deep-link even if it exists
else
// Follow deep-link除了它既粗糙又丑陋之外,你能看到周围的工作有什么问题吗?
编辑:工作周围的工作,只有当我负责发送意图与深度链接。因为没有外部源可以知道"ignoreWhenLaunchedFromHistory“的额外信息。
发布于 2015-09-18 14:22:59
据我所知,在清单上使用android:excludeFromRecents="true"(作为活动声明的属性)可能会改善这个问题?
https://stackoverflow.com/questions/24284552
复制相似问题