Android singletop singleinstance and singletask

泄露秘密 提交于 2019-12-09 16:52:02

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/2308942/android-singletop-singleinstance-and-singletask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!