Code Monkey home page Code Monkey logo

Comments (1)

HERE-SDK-Support-Team avatar HERE-SDK-Support-Team commented on June 11, 2024

Hi @SergeHelfrichPI, sorry for the late reply and thank you for your detailed question. With the steps listed, this is expected, in such a case you need to recreate the map view. Basically, this is what the error message is indicating.

@Override
protected void onPause() {
    mapView.onPause();
    super.onPause();
}

@Override
protected void onResume() {
    mapView.onResume();
    super.onResume();
}

@Override
protected void onDestroy() {
    mapView.onDestroy();
    disposeHERESDK();
    super.onDestroy();
}

@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
    mapView.onSaveInstanceState(outState);
    super.onSaveInstanceState(outState);
}

When you call mapView.onSaveInstanceState(outState) then all map items that are added to the map, like markers, polylines and so on, will be kept based on the bundled state - even if the screen orientation changes. However, if instead you want to create a new map view instance for each orientation change, then make sure to reinitialize the HERE SDK and call mapView.onCreate(null) - a new HERE SDK instance or likewise a new MapView instance cannot be used together with a bundled state that was created based on previous instances.

If this answer is not sufficient, please leave a reply. Thank you!

UDPDATE: Here is a little bit more background info. In the example app, the HERE SDK is destroyed since there is only a single activity. In a more complex app it is also possible, to keep the HERE SDK alive and only destroy it when the app itself is terminated. Then, when an orientation change occurs, it does not need to be recreated. For example, an application can check if the saved bundle is not null, and thus do not recreate the SDK. This way, the stored map view instance can be reused. On the other hand - when the SDK should be also reinitialized, then also the map view instance needs to be recreated and thus, calling mapView.onCreate(null) is needed. The map view instance can only be reused by the same SDK instance. If the SDK instance changes, then also the map view instance needs to be recreated.

from here-sdk-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.