+ Reply to Thread
Results 1 to 5 of 5

Thread: Map went blank after rotation

  1. #1
    Tiger Leung
    Join Date
    Apr 2010
    Posts
    16
    Points
    0
    Answers Provided
    0


    0

    Default Map went blank after rotation

    Hi guys,

    I developed my first app with the Android API. Everything seems working as expected, except that the map goes blank after the device rotates. The error thrown in Eclipse is as follow:
    03-09 15:52:46.363: E/libEGL(8091): call to OpenGL ES API with no current context (logged once per thread)

    I didn't do anything special for handling the rotation. All map initialization is in OnCreate.

    Any idea about how to fix the error or handle the rotation?

    Thanks

  2. #2
    Stephen Quan
    Join Date
    Jul 2010
    Posts
    43
    Points
    11
    Answers Provided
    6


    0

    Default Re: Map went blank after rotation

    Did you remember to implement onPause() and onResume() as per the HelloWorldMap sample?
    Neglecting to do so can cause the map control not play nice with the Android application life cycle.

    Code:
    	protected void onPause() {
    		super.onPause();
    		map.pause();
    	}
    
    	protected void onResume() {
    		super.onResume();
    		map.unpause();
    	}

  3. #3
    EDWIN SANCHEZ
    Join Date
    Jul 2011
    Posts
    2
    Points
    1
    Answers Provided
    0


    0

    Unhappy Re: Map went blank after rotation

    I'm having this same issue. I have the "onPause" and "onResume" methods but my map is still being cleared after rotating the device. This is not good since doing so calls onCreate once again and my map loading process is a little too expensive to be repeating.
    HELP!

  4. #4
    Simon Klein
    Join Date
    Mar 2011
    Posts
    85
    Points
    21
    Answers Provided
    4


    0

    Default Re: Map went blank after rotation

    Hi,
    have a look at this thread:
    http://forums.arcgis.com/threads/527...ges-map-extent

    As i stated there:

    There is also the NOT recommended way of your activity just not acting on the rotation change.
    Would look something like this.
    Code:
    <activity android:name="YourMapActivity" android:configChanges="keyboardHidden|orientation">
    I'm doing the same in my app because of the loading expenses. Sometimes you have to work a little against the recommendations...

  5. #5
    Ivan Bespalov
    Join Date
    Apr 2010
    Posts
    334
    Points
    306
    Answers Provided
    51


    0

    Default Re: Map went blank after rotation

    Please explain me, what are you discussing about?

    (1) Map Rotation or (2) device flipping (and map rotation as result of it)?

    (1) - Clear - it works.

    (2) - Need to write code around it
    onRetainNonConfigurationInstance()
    NB! This method is deprecated.
    Code:
    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;
    }
    setRetainInstance(boolean)
    We has no time to try it ... So, when you solve problem paste your code.

    Good luck.

    P.S. This link (PDF) as bonus (contains link to WaterServiceApplication sample)
    Last edited by ibespalov; 03-16-2012 at 01:51 AM.
    Ivan

    Samples

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts