Ok, so I found this article on the web:

http://www.kidfloor.com/gamma-point/content/android-how-have-multiple-activities-under-single-tab-tabactivity

which seemed like what I was trying to do. Basically, I've got a tabbed
interface where each tab contains an activity, and a few of these activities
need to open child activities. Before I found the above article, I was just
creating an intent where I set the class to the child activity and used
startActivity(intent) to start this child activity. But, by doing that, when
the child activity launched it would cover up my tab navigation, which is
not the behavior desired.

So by using this piece of code from the above article inside my parent
activity:

public void replaceContentView(String id, Intent newIntent) {
     View view = getLocalActivityManager().startActivity(id,

newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                            .getDecorView();
     this.setContentView(view);
}

Where the newIntent is the intent for my child activity and the parent
activity extends the ActivityGroup class. I was able to get the results I
wanted in the sense that my child activity gets placed on top of my parent
activity, but the tab navigation is still there. However, upon reading up on
FLAG_ACTIVITY_CLEAR_TOP I discovered that the parent activity basically gets
destroyed by doing this which is not what I want.

The weird thing is though, I was putting Log statements in each of the
lifecycle functions to see if in fact the parent activity was destroyed but
the Log statements were never printed to the log in the Debugger so I
couldn't quite figure out what was happening. However when I returned from
the child activity using the following code:

Intent parent = new Intent(v.getContext(), Home.class);
Home parentActivity = (Home)getParent();
parentActivity.replaceContentView("info", parent);

I could see in the debugger that my objects in the parent activity were
being re-created as if the activity was starting for the first time. And I
tried using the back button from my child activity and it closed my app and
went back to the home screen, which leads me to believe that the parent
activity is definitely being destroyed since it's not on the activity stack
to go back to.

So I guess my question is...is there a better way to get the behavior I want
visually along with the behavior I want functionally? I would think that I
should be able to save the state of the parent activity and use that to
re-create it, however if none of the lifecycle or onSaveInstanceState
methods are being called then how would I go about doing this?  The only
other thing I could think of is to create a new tab and place the contents
of my child activity as a new tab in the navigation.

I hope this helps explain what I'm trying to do...Thanks for all the help,
DanielleM

On Tue, Feb 15, 2011 at 10:33 PM, TreKing <[email protected]> wrote:

> On Tue, Feb 15, 2011 at 2:31 PM, DanielleM <[email protected]> wrote:
>
>> I'm using an intent flag "FLAG_ACTIVITY_CLEAR_TOP" so that a
>> child activity can be placed on top of the parent activity without
>> covering up my tab navigation.
>>
>
> You may want to explain this. I'm not sure what you mean by this and I'm
> thinking you may not actually want the functionality CLEAR_TOP offers.
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

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

Reply via email to