I am trying to modify screenBrightness through update this:
window.attributes = window.attributes.apply { screenBrightness = 0.2f }
But I can get window in MainActivity : ComponentActivity() only. How to access is from Composable component?
I am using this to modify screen brightness in Jetpack Compose
@Composable
fun ComposableComponent() {
val activity = LocalView.current.context as? Activity
if (activity != null) {
activity.window?.attributes = activity.window.attributes.apply {
screenBrightness = -1.0f
}
}
}