Skip to content

Instantly share code, notes, and snippets.

@itome
Created December 3, 2018 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itome/bd9859f2d9fa4362401c5e856e8e6f81 to your computer and use it in GitHub Desktop.
Save itome/bd9859f2d9fa4362401c5e856e8e6f81 to your computer and use it in GitHub Desktop.
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