Okay folks, I seem to have found a solution thanks to the helpful
people who posted above.
Here it is...
1. Create a new class called TabbedMapActivity
2. Paste this in the new class:
import android.app.Activity;
import android.app.LocalActivityManager;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
/**
* A screen that contains and runs multiple embedded activities.
* AND NOW... allows you to contain a MapView
* Edited by Miles
*/
public class TabbedMapActivity extends MapActivity {
private static final String STATES_KEY = "android:states";
/**
* This field should be made private, so it is hidden from the
SDK.
* [EMAIL PROTECTED]
*/
protected LocalActivityManager mLocalActivityManager;
public TabbedMapActivity() {
this(true);
}
public TabbedMapActivity(boolean singleActivityMode) {
mLocalActivityManager = new LocalActivityManager(this,
singleActivityMode);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle states = savedInstanceState != null
? (Bundle) savedInstanceState.getBundle(STATES_KEY) :
null;
mLocalActivityManager.dispatchCreate(states);
}
@Override
protected void onResume() {
super.onResume();
mLocalActivityManager.dispatchResume();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Bundle state = mLocalActivityManager.saveInstanceState();
if (state != null) {
outState.putBundle(STATES_KEY, state);
}
}
@Override
protected void onPause() {
super.onPause();
mLocalActivityManager.dispatchPause(isFinishing());
}
@Override
protected void onStop() {
super.onStop();
mLocalActivityManager.dispatchStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
mLocalActivityManager.dispatchDestroy(isFinishing());
}
public Activity getCurrentActivity() {
return mLocalActivityManager.getCurrentActivity();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
3. In the Activity which contains both the TabHost and your MapView
change the "extends" to extend your new class, e.g:
extends TabbedMapActivity
4. When you call setup() on your TabHost, change it to read:
tabs.setup(mLocalActivityManager);
(This references the LocalActivityManager we just created in the
TabbedMapActivity we defined in step 2)
5. Rebuild and run!
This works for me, so now I can have a MapView and a TabHost which
includes Intents as content to each tab in the TabHost.
Hope this helps someone and again thanks for those who helped me with
this!
-Miles
On Dec 9, 2:15 am, "Dianne Hackborn" <[EMAIL PROTECTED]> wrote:
> Fyi, ActivityGroup is very simple and as far as I know doesn't use any
> internal methods:
>
> http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_...
>
> It's basically the same as ListActivity, a convenience class for a common
> pattern that you can implement yourself.
>
>
>
> On Mon, Dec 8, 2008 at 4:41 PM, Mark Murphy <[EMAIL PROTECTED]> wrote:
>
> > mscwd01 wrote:
> > > Anyone? I'm guessing its possible but I cant find an obvious
> > > solution...
>
> > Alas, I don't think it is possible, unless you fancy getting your hands
> > dirty in the Android source code.
>
> > You need the activity that is managing the tabs to be an ActivityGroup
> > if you want one or more tabs to contain Intent-launched activities. The
> > only such class is TabActivity.
>
> > Similarly, AFAIK, you need to use MapActivity for your MapView to work.
>
> > Your only hope is to get the Android source code for TabActivity and
> > MapActivity and attempt to merge them yourself to create
> > TabbedMapActivity, so you can have an ActivityGroup subclass that
> > implements both tabbing and mapping behavior.
>
> > Having written a section in Version 1.9 of my book on using Intent-based
> > tabs in a TabActivity, I confess as to having no real good idea why
> > anyone would want to use one. The only scenario I can see is if you need
> > something that can be run independently as an activity *and* appear as a
> > tab in another activity...but that can be solved just by separating
> > those smarts out into a separate Java class and reusing the logic in
> > both spots.
>
> > --
> > Mark Murphy (a Commons Guy)
> >http://commonsware.com
>
> > Android Training on the Ranch! -- Mar 16-20, 2009
> >http://www.bignerdranch.com/schedule.shtml
>
> --
> Dianne Hackborn
> Android framework engineer
> [EMAIL PROTECTED]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support. All such questions should be posted on public
> forums, where I and others can see and answer them.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---