Reputation: 4408
In my application i have a tabhost with one tab for "map"
On clicking map i am launching a new activity within which i am launching the google map using intent.
Now when i click on "back" key, i get the tab view with map tab being pressed and below a blank screen.
If i click map again, screen remains the same , map is not launched again.
How can i get the map displayed whenever i press map. Like i press anyother tab and again press map , it should display map.
Here is my code launching the map:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setMapView();
}
private void setMapView() {
// get lat , log here
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:" + latitude + "," + longitude+ "?z=10" ) );
startActivity(intent);
}
Upvotes: 1
Views: 723
Reputation: 17820
It sounds like you're launching an activity which then immediately launches the map activity. This is overly complicated and it is causing problems for you. Get rid of the activity in the middle. You could simply open the activity by writing your own onTabChangeListener for the TabHost.
Another problem is that you're launching an activity when the user selects a tab. That is confusing behavior. It would be more appropriate to open your map activity from a button or menu item. The code inside setMapView() should instead go into the onClick method for whichever control you decide to use.
Upvotes: 1