public void onCreate(Bundle savedInstanceState) { // ... mapView = (MapView) findViewById(R.id.map); // ... Object[] init = (Object[]) getLastNonConfigurationInstance(); if (init != null) { mapView.restoreState((String) init[0]); tiledMapServiceLayer = (ArcGISTiledMapServiceLayer) init[1]; graphicsLayer = (GraphicsLayer) init[2]; } else { mapView.setExtent(new Envelope(-85.61828847183895, 38.19242311866144, -85.53589100936443, 38.31361605305102)); tiledMapServiceLayer = new ArcGISTiledMapServiceLayer(this, mapURL); graphicsLayer = new GraphicsLayer(this); } // ... } // ... public Object onRetainNonConfigurationInstance() { Object appState = new Object[] { mapView.retainState(), tiledMapServiceLayer, graphicsLayer }; mapView.removeAll(); return appState; }
There is also the NOT recommended way of your activity just not acting on the rotation change.Would look something like this. <activity android:name="YourMapActivity" android:configChanges="keyboardHidden|orientation">
<activity android:name="YourMapActivity" android:configChanges="keyboardHidden|orientation">
protected void onPause() { super.onPause(); map.pause(); } protected void onResume() { super.onResume(); map.unpause(); }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.