Thursday, June 24, 2010

[android-developers] Task Switching in Activities - confused.

I've read through the stuff about Activities and tasks and I guess I
don't completely understand it.

Here's the scenario.

I have my main activity which is singleInstance.
I launch a PreferenceActivity via startActivityForResult.
PreferenceActivity is now active.
I press the Home Screen and navigate away from PreferenceActivity.
I hold down the home screen button to see recent tasks. I see the
program icon and click it.
This brings me back to the preference screen. Not what I wanted - I
want it to do
I push the back button. It closes the PreferenceActivity but doesn't
take me back to the main activity.
I can only get back to that main activity by going back to the apps
area and clicking the icon, even though it is still running.

I try to rememedy the situation by setting
excludeFromRecentTasks="true" in the Preference Activity. Now, when I
navigate away from the PreferenceActivity, there is no trace of my
program icon in the recent task history.

This is what I would like to have happen:
Have my app icon in the recent tasks when someone holds down.
Have clicking on it lead to the main activity.

I see this attribute, which sounds promising:

The clearTaskOnLaunch attribute
If this attribute is set to "true" in the root activity of a task, the
stack is cleared down to the root activity whenever the user leaves
the task and returns to it. In other words, it's the polar opposite of
alwaysRetainTaskState. The user always returns to the task in its
initial state, even after a momentary absence.

But it doesn't help. I'm still getting stuck in the preference
activity.

I'm lost.

Nathan

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment