Skip to content

Instantly share code, notes, and snippets.

@hvisser
Created January 21, 2022 09:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvisser/de8686e7a82df94d2607100206d2df04 to your computer and use it in GitHub Desktop.
Save hvisser/de8686e7a82df94d2607100206d2df04 to your computer and use it in GitHub Desktop.
LocalView.current can be useful if you need to tap into a view function like keepScreenOn or haptics from Compose
@Composable
fun KeepScreenOn() {
val currentView = LocalView.current
DisposableEffect(Unit) {
currentView.keepScreenOn = true
onDispose {
currentView.keepScreenOn = false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment