Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android singletop singleinstance and singletask

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

like image 513
user278445 Avatar asked Feb 22 '10 05:02

user278445


People also ask

What is the difference between singleTop and singleTask?

standard and singleTop comes in one side and singleTask and singleInstance comes in another side. The main difference between standard and singleTop is in standard, every time a new intent for standard activity, a new instance is created.

What is Android singleInstance?

SingleInstance. Remember this as: Single Instance in Single Task. In this android launch mode, just like Single Task a new Task is created and the activity placed at the root. But this new task will only contain that activity instance and nothing else.

How do I use singleTask on Android?

Single Task In this method of operation, a new task is always generated, and a new instance is added to the task as the root one. If the activity already exists on another task, no new instance is created, and the Android system transmits the intent information via the onNewIntent() function.

What is meant by singleTop in activity instance?

2. singleTop. In this launch mode if an instance of activity already exists at the top of the current task, a new instance will not be created and Android system will route the intent information through onNewIntent(). If an instance is not present on top of task then new instance will be created.


1 Answers

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.

like image 79
rjschnorenberg Avatar answered Oct 20 '22 17:10

rjschnorenberg