> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/android/ja/maps/llms.txt)

# Multi display

![Display the map on a secondary display.](https://docs.mapbox.com/android/ja/assets/ideal-img/maps-compose-examples-multi-display.924369f.480.png)

This example showcases how to display a map in a secondary display using **Mapbox Maps SDK for Android**. The activity handles creating and setting up the map view with options to show or hide the map on the default or secondary display. It uses [`MapboxMapComposeTheme`](https://github.com/mapbox/mapbox-maps-android/blob/main/compose-app/src/main/java/com/mapbox/maps/compose/testapp/ui/theme/Theme.kt) for theming and [`MapViewportState`](https://docs.mapbox.com/android/maps/api/latest/mapbox-maps-android/com.mapbox.maps.extension.compose.animation.viewport/-map-viewport-state/) for managing the map's viewport state, including setting the camera options like centering on `CityLocations.HELSINKI` with a specific zoom level. City location data is imported from an examples utility file.

The `displayMapInSecondaryScreen()` method retrieves the `DisplayManager` system service to find the secondary display and uses `ActivityOptions` to configure the display settings before launching a new intent to show the map on the secondary screen. If the secondary screen is not found, a toast notification indicates that the second screen is not available for display. The `SimpleMapActivity` class is used to show the map on the secondary display.

> **Note: Android Examples App Available**
> 
> This example code is part of the **Maps SDK for Android Examples App**, a working Android project [available on GitHub](https://github.com/mapbox/mapbox-maps-android/tree/v11.29.0/). Android developers are encouraged to run the examples app locally to interact with this example in an emulator and explore other features of the Maps SDK.
> 
> See our [Run the Maps SDK for Android Examples App](https://docs.mapbox.com/help/tutorials/maps-sdk-android-examples-app/) tutorial for step-by-step instructions.

**Kotlin**

Title: `MultiDisplayActivity.kt`

[View on GitHub](https://github.com/mapbox/mapbox-maps-android/blob/v11.29.0/compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/basic/MultiDisplayActivity.kt)

```kt
package com.mapbox.maps.compose.testapp.examples.basic

import android.app.ActivityOptions
import android.content.Context
import android.content.Intent
import android.hardware.display.DisplayManager
import android.os.Build
import android.os.Bundle
import android.view.Display
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.mapbox.maps.compose.testapp.ExampleScaffold
import com.mapbox.maps.compose.testapp.examples.utils.CityLocations
import com.mapbox.maps.compose.testapp.ui.theme.MapboxMapComposeTheme
import com.mapbox.maps.extension.compose.MapboxMap
import com.mapbox.maps.extension.compose.animation.viewport.rememberMapViewportState

/**
 * Showcase showing a map in a secondary display.
 */
public class MultiDisplayActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
      var mapOnDefaultDisplay by remember {
        mutableStateOf(false)
      }
      MapboxMapComposeTheme {
        ExampleScaffold(
          floatingActionButton = {
            Column {
              FloatingActionButton(
                modifier = Modifier.padding(bottom = 10.dp),
                onClick = {
                  mapOnDefaultDisplay = !mapOnDefaultDisplay
                },
                shape = RoundedCornerShape(16.dp),
              ) {
                val action = if (mapOnDefaultDisplay) "Hide" else "Show"
                Text(modifier = Modifier.padding(10.dp), text = "$action map on default display")
              }
              FloatingActionButton(
                modifier = Modifier.padding(bottom = 10.dp),
                onClick = {
                  displayMapInSecondaryScreen()
                },
                shape = RoundedCornerShape(16.dp),
              ) {
                Text(modifier = Modifier.padding(10.dp), text = "Show map on secondary display")
              }
            }
          }
        ) {
          if (mapOnDefaultDisplay) {
            MapboxMap(
              Modifier.fillMaxSize(),
              mapViewportState = rememberMapViewportState {
                setCameraOptions {
                  center(CityLocations.HELSINKI)
                  zoom(15.0)
                }
              }
            )
          }
        }
      }
    }
  }

  private fun displayMapInSecondaryScreen() {
    val displayManager = getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
    displayManager.displays.firstOrNull {
      it.displayId != Display.DEFAULT_DISPLAY
    }?.apply {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        // Use activity options to select the display screen.
        val options = ActivityOptions.makeBasic()
        options.launchDisplayId = displayId
        val intent = Intent(this@MultiDisplayActivity, SimpleMapActivity::class.java)
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        // To display on the second screen, the intent must be launched using singleTask launchMode.
        startActivity(
          intent,
          options.toBundle()
        )
      }
    }
      ?: Toast.makeText(this, "Second screen not found.", Toast.LENGTH_SHORT).show()
  }
}
```