This example demonstrates how to change the appearance of an interactive map by downloading a map style from the content store and applying it to the map view.
MainActivity overrides onCreate, which inflates the view binding, calls setContentView(binding.root) for the layout in res/layout/activity_main.xml, and enables edge-to-edge drawing so the map fills the screen. It then registers the SDK listeners and checks for an internet connection, since the styles are fetched online.
When the activity is destroyed, onDestroy clears the listeners, deinitializes the SDK with GemSdk.release(), and exits the process.
The layout hosts a full-screen com.magiclane.sdk.core.GemSurfaceView that renders the map, plus a status_text panel and a progress indicator used to report what the app is doing.
Styles are downloaded from the content store, which requires a verified app token. registerSdkListeners() waits for SdkSettings.onConnectionStatusUpdated to report a connection, then verifies the app authorization with SdkSettings.verifyAppAuthorization. It self-clears after the first connection event so verification runs only once. The surface callbacks handle init failure and keep the Magic Lane logo aligned with the system insets.
fetchAvailableStyles() asks the content store for the list of map styles with contentStore.asyncGetStoreContentList(EContentType.ViewStyleHighRes, ...). When the list arrives, the example picks one style and downloads it; in a real app the user would choose. To showcase a clearly non-default look, it selects the style at the midpoint of the list (or the only one if the list has a single entry).
startDownloadingStyle(style) first checks the item's status: if it is already EContentStoreItemStatus.Completed - downloaded in a previous session - it applies the style immediately. Otherwise it starts the download with ContentStoreItem.asyncDownload, and applies the style in the onCompleted callback once the data is local.
Applying the style is the core of this example: applyStyle() sets the downloaded style on the map view with preferences?.setMapStyleById(style.id). The map redraws immediately with the new appearance.
Because the map draws edge-to-edge, updateFocusViewport() keeps the Magic Lane logo visible by setting the map view's focusViewport to the area free of the system insets - or above the status panel when it is showing. Map access runs on the SDK thread inside SdkCall.runSynced.
clearSdkListeners() is called from onDestroy to detach every SDK callback before the activity goes away, so a late callback can never reach a destroyed activity.