multiuser application managing back stack of each user
everybody
I work on multiuser application, which is REST client, so when you launch it, the 1st activity you see is LoginActivity.
For example, I have ten activities and LoginActivity and I can navigate e.g. next way: LoginActivity -> Activity1 -> Activity3 -> Activity8(logout) -> LoginActivity. I can do log out from every activity.
Possible next situation:
1) user1 logged in: LoginActivity -> Activity1 -> .. Activity7(logout) -> LoginActivity. 2) user2 logged in: LoginActivity -> Activity1 -> .. Activity4(logout) -> LoginActivity. 3) user1 logging in again: LoginActivity -> Activity7.. and user1 must naturally go to Activity7 with his last back stack if possible.Also user must see only relevant for him data.
Is there any mechanisms to manage all this stuff? I mean, does a开发者_JAVA百科ndroid platform support such multiuser apps, or restoring/storing back stack manually.
Any other ideas?
p.s. I found workaround to use SharedPrefences for each user to store only his data and store activity he logged in from. But it seems not android way as for me.
UPD: I done some research, and found out two intent flags to launch new task with it`s back stack history: (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK)
So, as I understand, in case of above example LoginActivity is something like "top level launcher" mention in javadoc of FLAG_ACTIVITY_MULTIPLE_TASK.
But, I cannot find docs/sample of top level launcher; how to manage tasks by their IDs. Please help with top level launcher sample or managing tasks api.
UPD2: I found how some functions how to manipulate tasks by task id:
public void moveTaskToFront (int taskId, int flags); but it is only since API level 11 But I use level 7, is there any technique how to move task to foreground?There is no way of managing tasks since "it isn't really how tasks
are supposed to work. The whole point of them is that they are entirely separate, unrelated things"
I solved a similar problem inspired in this solution although. In this solution, you keep track of the activities
being used, so it suits your idea, I think. I don't think you will be using a tab system, so discard the bottom part. The important part is the ActivityGroup
management.
I hope this helps.
精彩评论