活动开启后恢复正常工作流程

发布于 2024-12-15 15:19:25 字数 301 浏览 0 评论 0原文

让我们举一个简单的例子,我有一个提供 HomeActivity 的应用程序,此活动可以导致一个 RssListActivity(列出 RSS 项目),它可以导致第三个 ItemDetailActivity,它仅提供我的 RSS 项目的详细视图。某些通知可能会导致在定义的文章上打开 ItemDetailActivity。

我的观点是,在通知的情况下,恢复正常的工作流程,即当用户单击后退按钮时,他将进入 RssListActivity,再次单击后退按钮将进入 HomeActivity。

当然,我真的不想在每个活动上重写自定义的 onKeyDown() 。

Let's take a simple example, I have an application that present a HomeActivity, this activity can lead to a RssListActivity (that list RSS items) which can lead to a third ItemDetailActivity which simply provide a detailed view of my RSS item. Some notifications may lead to the opening of ItemDetailActivity on a defined article.

My point is, in the case of a notification, to restore the normal workflow i.e. when the user click on the back button he is bring to the RssListActivity and another click on the back button brings to the HomeActivity.

Of course I would really like not to have to override a custom onKeyDown() on each of these activities.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韶华倾负 2024-12-22 15:19:26

希望我正确理解了你的问题,

你想确保在流程中:

Home >任务1> Task2

如果调用通知来启动“Task1”,则返回堆栈将如下所示:

Home >任务2> Task1

您可以通过添加 FLAG_ACTIVITY_REORDER_TO_FRONT 来完成此操作调用Task1的Intent。它应该将 Activity(如果正在运行)重新排序到 Backstack 的顶部。

Hopefully I've understood your question correctly,

You want to make sure that in the flow:

Home > Task1 > Task2

That if a notification is called to start "Task1" then the backstack will look like this:

Home > Task2 > Task1

You can do this by adding FLAG_ACTIVITY_REORDER_TO_FRONT to the Intent which is calling Task1. It should reorder the Activity (if running) to the top of the Backstack.

夏日落 2024-12-22 15:19:26

我认为你一定不要重新排序活动,最好为用户提供两种导航方式。用户习惯的 Android 方式,如果您的应用程序有某种需要保留的层次结构,您可以在应用程序中设置一个 ActionBar,并带有一个返回按钮(以分层方式)

此外,我认为唯一的方法做你想做的就是重写 onKeyDown 方法。

I think that you must not reorder the activities, It's better to give to the user the two ways of navigation. Android way that the user is used to, and if your applications have some kind of hierarchy that needs to preserve you can have a ActionBar in your application with a button to go back (in the hierarchical way)

Also, I think the only way to do what you want is overriding the onKeyDown method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文