Android singletop 单实例和单任务

发布于 2024-08-23 00:05:18 字数 903 浏览 6 评论 0原文

我在为不同的活动实现不同类型的启动模式时遇到设计问题。我有 5 项活动。

  1. VideoList

  2. VideoDetail

  3. 收藏列表
  4. VideoSearch

  5. VideoPlayer

当用户启动应用程序它会转到显示视频列表的 VideoList。单击任何视频会将它们带到视频详细信息。该页面中有两个按钮。播放按钮和添加到收藏夹按钮。我在所有页面上都有一个页脚栏。页脚栏包含三个图像按钮。

1 主页 - 将用户带到首页 - 视频列表页面

2 收藏夹列表 - 显示收藏夹视频列表。单击任意一个视频,用户将进入视频详细信息

3 视频搜索 - 用户可以按艺术家姓名搜索视频。单击任何一个视频都会使用户看到视频详细信息

我的问题是,如果我将所有活动设置为标准,则会占用大量内存。因为用户可以从每个页面打开新的活动。

1.我的选择是什么?

2.我可以使用 SingleInstance / SingleTop (在所有活动上还是仅在某些活动上)?

3.我尝试在所有活动上使用 SingleTop。它在大多数情况下都能正常工作。除了一个。

用户打开应用程序。

b.单击视频列表页面中的一项。它打开一个新活动 - VideoDetail

c。在“视频详细信息”页面中,用户单击“收藏夹列表”图像按钮,这将打开一个新活动“收藏夹列表”。

d.当用户单击收藏夹中的视频之一时,它不会打开新的视频详细信息,而是关闭收藏夹列表并返回到详细信息页面。

请帮忙

提前谢谢

RM

I've an design issue in implementing different types of launchmode for different activities. I've 5 Activities.

  1. VideoList

  2. VideoDetail

  3. FavoritesList

  4. VideoSearch

  5. VideoPlayer

When the user starts the app it goes to VideoList that displays list of videos. Clicking on any of the Videos take them to VideoDetails.There are two button in that page. Play Button and Add to Favorites Button. I've a Footer bar on all the pages. Footer bar contains three image button.

1 HOME - Takes the user to first page- video list page

2 FAVORITES LIST - Show the list of favorites video. Clicking on any one of the videos takes the user to video details

3 VIDEO SEARCH - user can search video by artist name. Clicking on any one of the videos takes the user to video details

My question is , if I set all the activities to standard, it eats lot of memory. Because user can open new activity from each page.

1. What are my choices?

2. Can I use SingleInstance / SingleTop (on all activities or only some activity )?

3. I tried to SingleTop on all activities. It works fine on most of the cases. Except for one.

a. User opens the app.

b. Click on one of the item in video list page. It opens a new activity - VideoDetail

c. From VideoDetail page, user clicks the favorites list image button which opens a new activity FavoritesList.

d. When the user clicks the one of the videos from favorites, its not opening a new video detail, its closing the favorites list and goes back to detail page.

Please help

Thanks in advance

RM

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

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

发布评论

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

评论(1

云胡 2024-08-30 00:05:18

如果您想在这种情况下使用 SingleTop,那么您需要将加载视频详细信息的代码从 onCreate 移动到 onResume,因为 VideoDetail 活动仅创建一次,然后每当意图尝试再次启动它时就恢复。

If you want to use SingleTop in this instance then you need to move the code that loads the video details from onCreate to onResume as the VideoDetail activity is only being created once and then resumed whenever an intent tries to launch it again.

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