Last active
October 19, 2020 07:49
-
-
Save huuphuoc1396/875a15d136e21a94490fe979a6fa523c to your computer and use it in GitHub Desktop.
Start secondary activity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (displays.size > 1) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
// Activity options are used to select the display screen. | |
val options = ActivityOptions.makeBasic() | |
// Select the display screen that you want to show the second activity | |
options.launchDisplayId = displays[1].displayId | |
// To display on the second screen that your intent must be set flag to make | |
// single task (combine FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NEW_TASK) | |
// or you also set it in the manifest (see more at the manifest file) | |
startActivity( | |
Intent(this@MainActivity, SecondActivity::class.java), | |
options.toBundle() | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment