Created
December 3, 2018 06:39
-
-
Save itome/bd9859f2d9fa4362401c5e856e8e6f81 to your computer and use it in GitHub Desktop.
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
private fun getApplicationOrientation(): Int { | |
val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager | |
val rotation = windowManager.defaultDisplay.rotation | |
return when (rotation) { | |
Surface.ROTATION_0 -> 0 | |
Surface.ROTATION_90 -> 90 | |
Surface.ROTATION_180 -> 180 | |
Surface.ROTATION_270 -> 270 | |
else -> throw IllegalStateException() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment