views:

127

answers:

1

My android app contains a suite of mini apps. In short, the main screen contains several icons, one each for the mini apps. When an icon is clicked, the mini app is launched. In total I have 4 mini apps. So you could imagine that my main screen is like the Home Screen Launcher. Although these mini apps could run standalone by their own, I want the user to be authenticated. Thus there is a LoginActivity right before the MainActivity.

LoginActivity -> MainActivity ---> AppOneActivity
                              ---> AppTwoActivity
                              ---> AppThreeActivity
                              ---> AppFourActivity (aka PresenceListActivity)

I'm still not pretty sure of the benefit of Tasks (arranged set of Activities), so I would like comments from Android experts on my design decisions:-

(1) I plan to set the attribute finishOnTaskLaunch to true for LoginActivity. As I understand it, once the login is authenticated, I will navigate the user to MainActivity, and I want LoginActivity to disappear. Is this better than calling #finish on the Activity ? Will MainActivity automatically become the root of the Task without any extra configuration/code ?

(2) One of the mini app is an IM client. The PresenceListActivity will hosts many instances of ChatActivity (one-to-one chat session with an active contact in the buddylist). I plan to use the default launchmode for ChatActivity since each Chat should be handled by a new instance. Sounds correct ?

(3) A sticky navigation bar will exists in the top corner of AppOneActivity, AppTwoActivity etc.. I plan to set the clearTaskOnLaunch attribute to true for all of them. As I understand it, I should clear the stack whenever I plan to launch into any of the mini apps. Also their launchModes will be singleTask. Am I on the right path ?

(4) Finally I don't really understand how to read the output of adb shell dumpsys activity. For example

Task{10 com.me.rnd.exit}
clearOnBackground=false numActivities=1
affinity=com.me.rnd.exit
lastActiveTime=5513102 (inactive for 5s)
  History #1: .....

Task{2 com.android.launcher}
clearOnBackground=true numActivities=1 rootWasReset=true
affinity=com.android.launcher
lastActiveTime=5512949 (inactive for 6s)
  Running #0:

Sometimes underneath the Tasks, you will see History and in others Running, what do these mean ? Even stranger, sometimes I have two History under a task.

Thanks

A: 

(1) I plan to set the attribute finishOnTaskLaunch to true for LoginActivity. As I understand it, once the login is authenticated, I will navigate the user to MainActivity, and I want LoginActivity to disappear. Is this better than calling #finish on the Activity ? Will MainActivity automatically become the root of the Task without any extra configuration/code ?

I recommend making the MainActivity the root activity from the start.

First the MainActivity would create the LoginActivity or a LoginDialog and return the result to the MainActivity.

That way you won't have to figure out how to move the MainActivity from child to root activity.

However, if this interferes with your code too much then do not take my recommendation into consideration.

Cheers,

Joseph

The MainActivity needs to retrieve and load a lot of data, so I don't think your suggestion will work.
Jacques René Mesrine
What about have an Activity that handles showing the login activity or the Main Activity: LaunchActivity -> LoginActivity and LuanchActivity -> MainActivity First it launches the LoginActivity. After successfully logging in, the login activity finishes and goes away and the launcher shows the main activity