I see a lot of StackOverflow questions/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.
As self-appointed President of the Anti-Activity-Tab Alliance (AATA), that's certainly my position.
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.
Note that this has nothing to do with having activities as the contents of tabs.
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.
I'd avoid it if possible.
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.
This doesn't follow at all from what you wrote previously. Your "back events" will not change one iota between using Views as the contents of tabs and using Activities as the contents of tabs. Furthermore, this has nothing whatsoever to do with the "loose coupling" pattern you describe -- clicking on an icon in a list in a view in a tab is no different than clicking on an icon in a list in a view in an activity in a tab.
Just have your Show activity tell your, um, main activity to show a particular location, then the Show activity can finish()
. The simplest way to do that without introducing a hard JVM coupling between the activities is to broadcast an Intent
and register a BroadcastReceiver
in the main activity. Upon receipt of this Intent
, the main activity would update the map and set it to be the current tab. Of course, this approach is simpler if you have the main activity use Views for its tab contents.
Now, if you try to overhaul your application, such that navigating in a tab doesn't launch another activity, but rather keeps things within its own tab...that is a whole 'nuther kettle of fish.