views:

43

answers:

2

Hi all! I had found a lot of stackoverflow post about save an Activity and the reload it. My question: How can I have an Activity with an MapView and after reload the same mapview ? What is the best way to switch between activity and views ? Thanks:Karoly

A: 

If you mean save the current view you can always save the current center point and zoomlevel so you that you can re-center the map to the last position. But if you mean just going from your MapActivity to a new Activity and coming back, the view should still be the same.

BrennaSoft
In my App I have one Activity (MapActivity) and a lot of other view witch are representing some another screen. If I start a view and I would like to come back to the Map Activity I can't . . . I got a new Activity, witch is not so good :(
Karoly
A: 

If I understand correctly what you ask, you need to come back from your other activities to the same instance of MapActivity that you first have run.

In order to do that, from your other activity, just start the MapActivity with an Intent with the flag FLAG_ACTIVITY_REORDER_TO_FRONT. This will not create a different instance of your MapActivity but bring to front your initial one.

kaciula
Hi!Thanks for the answare. I had tried it: The activity is started (the log file was said it ), but it won't come in the front of the view, so i can't see it:( What do you think ? Intent map = new Intent(BottomLayout.context, Map.class); map.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mainWindowActivity.startActivity(map);
Karoly
It's not clear what you're actually doing in your code. From your comment I understand that you have only one Activity with a MapView and that somehow you added a view on top of it. If that's the case, you can use setVisibility(View.GONE) on your view and it will disappear. Try to add parts of the code to your question so it can be understood what exactly are you doing. Because I'm just guessing right now.
kaciula
check this out please:http://digitus.itk.ppke.hu/~holkazs/android/
Karoly
on the doc, the mainWindowActivity is the MapActivity, I'm trying to use it to set the content and the layouts . . .
Karoly
You're mixing activities with views. Usually we have one activity with one view. When someone clicks one of the buttons in the MapActivity, you shouldn't use setContentView() on that Activity but instead launch a new Activity. In the onCreate() function of that new Activity, use setContentView(). To summarize, use several activities for your flow, each with a different view. This way, when you click back, you go to your previous Activity with its own view. Hope I was clear.
kaciula