title: Android - Tabs, MapView, activities within tabs
body: <p>We're in the process of writing an app that has 4 tabs: Map, People, Places, Events.  The People, Places, and Events in the App show up as Icons on the map.  By default the People, Places, and Events tabs each show a listview, custom rendered, displaying all the People, Places, and Events respectively.</p>
  
  <p><a href="http://web6.twitpic.com/img/37202700-f92052dc474b74e1760edda1c47f6940.4adcb134-scaled.png" rel="nofollow noreferrer">alt text http://web6.twitpic.com/img/37202700-f92052dc474b74e1760edda1c47f6940.4adcb134-scaled.png</a></p>
  
  <p>Now, right now each of the tabs has as its content an Intent set to launch the corresponding activity.  For instance, there is a MapTabActivity that extends MapActivity, a ShowPeopleListActivity that shows the people, and so on and so forth.  </p>
  
  <p>I see a <a href="https://stackoverflow.com/questions/1088810/how-to-communicate-between-android-tabs">lot</a> <a href="https://stackoverflow.com/questions/1306689/launching-activities-within-a-tab-in-android">of</a> <a href="https://stackoverflow.com/questions/1162659/best-way-to-accomplish-inter-activity-communication-in-an-android-tabhost-applica">StackOverflow</a> <a href="https://stackoverflow.com/questions/1568739/android-why-shouldnt-i-use-activities-inside-tabs">questions</a>/answers saying that due to various limitations in the way the TabHost is setup, it's best NOT to use activities as the content of tabs.  For instance, it's impossible to launch a new activity and have it take the place of the existing activity within a tab, whereas it's possible to switch out a View with a different view.  </p>
  
  <p>Now, I'm at a crossroads.  We've (for better or worse) devoted a fair amount of time trying to get this app to work the way it's currently structured, with the Activities as the content of the tabs.  When an icon corresponding to a Person, Place, or Event is clicked, it fires off a VIEW Intent on a URI corresponding to that object; this is picked up by an Activity that then shows the object.  The same mechanism is at work both in the Map and in the individual lists.  We really like the loose coupling this provides us; we just give a VIEW command and the URI to the person/place/event and it automatically brings us to the right activity.  Granted, the activity that's launched covers up the tab view rather than appearing inside of that, but we were willing to live with this.</p>
  
  <p>Here's an issue though:  from the Show activity, we want to be able to go back to the map, centered at that person, place, or event.  We can launch a new activity to show the map again, but now we have the map activity as the content of the tab, plus the show activity, plus the new map activity in the activity stack; given how resource intensive the map activity is, I'm guessing this is not the ideal way to go.</p>
  
  <p>I guess my question is, is there a GOOD tutorial somewhere showing exactly how to do complex tasks with a TabHost?  I've seen <a href="http://developer.android.com/guide/tutorials/views/hello-tabwidget.html" rel="nofollow noreferrer">HelloTabWidget</a>; I'm looking for something much more sophisticated than this.  I'm worried that if we switch to the View based way of doing things, we'll have to do a LOT of housekeeping to intercept all the back events, try to switch out the views, etc., etc., as well as strongly coupling our program in a way we don't want.  </p>
  
  <p>Any suggestions on a way forward would be extremely appreciated.  We're new to Android so we're trying to follow the established best practices, but it's difficult when the few examples we've seen are too simplistic for our use case.</p>