POST
|
Thank you for the quick response, even though it was bad news for me. I am now trying something different: I have a front page activity with a listview. Two of the choices lead to activities that causes maps to be displayed. I start the first activity and initialize and display the map. When the user hits the "back"-key I remove/clean up the map in the onStop method, and the front page is displayed again. When the user selects the second choice, I do exactly the same thing with a different map. I have tried the following in onStop: LocationService ls = map.getLocationService(); ls.stop(); graphicsLayer.recycle(); map.recycle(); but the app behaves unpredictably. Sometimes it works, sometimes it crashes or hangs with no error messages. Sometimes the recycle() command causes "call to OpenGL ES API with no current context (logged once per thread)" to appear in LogCat. What's the correct way (if possible) to clean up a map session when the map activity is finished?
... View more
01-26-2012
02:58 AM
|
0
|
0
|
662
|
POST
|
I need to display a map several places in an Android app. My problem is that the first map I create works fine, but the second one will not display the current position or any graphic markers. The maps are in different activities. I have tried to call map.recycle() when pausing the first activity, and this makes the second map display the graphic markers, but then I need to recreate the first map all over again, which causes me to think that I am going the wrong way about this. The code used to create the maps are identical in the two activities, except for the resource IDs which are different. What is the best way (or correct way) to have two maps active in two different activities in the same app? What should be done in the onCreate, onDestroy, onPause and onResume? Example code: // Credentials to access the map String tokenServiceUrl = "https://somewhere/arcgis/tokens"; String userName = "secret"; String password = "secret"; UserCredentials credentials = new UserCredentials(); credentials.setTokenServiceUrl(tokenServiceUrl); credentials.setUserAccount(userName, password); // Initialize the map map = (MapView) findViewById(R.id.closebyMap); String mapUrl = "http://path_to_mapserver"; ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer(mapUrl, credentials); map.addLayer(tiledLayer); graphicsLayer = new GraphicsLayer(); map.addLayer(graphicsLayer); Then I set up a setOnStatusChangedListener, wait until I get INITIALIZED, then add graphic markers and start localization. When receiving location changed, I zoom the map to the current location. Any help will be greatly appreciated!
... View more
01-25-2012
05:50 AM
|
0
|
22
|
5123
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|