问题
I've an design issue in implementing different types of launchmode for different activities. I've 5 Activities.
VideoList
VideoDetail
FavoritesList
VideoSearch
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