0

I have this issue: after screen orientation I try to (re)add Layer that I have previously removed in onDestroy(). If I look for a Layer in mapBoxMap.getLayer(String id), I get null, even if just before that I added this layer to the map. Logs show nothing suspicious.

Ubu
  • 1
  • 2
  • Layer are destroyed as part of the hosting activity lifecycle. They shouldn't be retained across activity instances – Tobrun Nov 13 '17 at 14:18
  • Thanks for your feedback. Actually, when `Activity` is recreated, inside a `Fragment` (to be more precise, I use [Conductor](https://github.com/bluelinelabs/Conductor)'s `Controller`.) I create new layers with the same ids that I added before `Activity` was destroyed. I don't understand, why layers (added **after** Activity was recreated) aren't available. – Ubu Nov 13 '17 at 20:40
  • Are you reusing the mapboxMap instance? If yes, this is also bound to the lifecyle so it shouldn't be reused. How are you setting your style url? (if possible do this as soon as possible eg. xml attrs, mapView#setStyleUrl or MapboxMapOptions. – Tobrun Nov 30 '17 at 12:47
  • I'm getting a new `mapboxMap` instance in Activity's `OnCreate()`, i.e. I create it only in one place and reuse it as long as Activity lives. As for the style, I set it in xml. Finally, I switched to a `SymbolLayer`, it solved my problem. But still, there's this issue. – Ubu Dec 01 '17 at 16:38

1 Answers1

0

Add this to the manifest, where ".MainActivity" is the Activity name,

<activity android:name=".MainActivity"
                android:configChanges="orientation|screenSize"
              / >
Samira
  • 71
  • 12