Like title said how to on click button to go system sleep, to turn off screen?
got this kotlin code:
@Composable
fun ButtonOnClickGoToSystemSleep() {
// Fetching the Local Context
val localContext = LocalContext.current
Button(onClick = {
val intent = Intent("android.intent.action.ACTION_REQUEST_SHUTDOWN")
intent.putExtra("android.intent.extra.KEY_CONFIRM", true)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
localContext.startActivity(intent)
}) {
Text(text = "Go to sleep",Modifier.padding(start = 10.dp))
}
By the way this is not working, got this from stackoverflow 5 or 10 years ago..