jean
02/27/2023, 1:03 PM@Composable
fun BrightQrCode(
saveCurrentBrightnessLevel: (Int) -> Unit,
qrCode: @Composable () -> Unit,
) {
val context: Context = LocalContext.current
saveCurrentBrightnessLevel(Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS))
if (Settings.System.canWrite(context)) {
Settings.System.putInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS, 255)
} else {
LaunchedEffect(Unit) {
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.data = Uri.parse("package:" + context.activity?.packageName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(context, intent, null)
}
}
qrCode()
}
The problem is that it’s not recomposing when navigating back after giving the permission to my app. How can I fix that?Jonas de Faria Alves
02/27/2023, 1:52 PMDisposableEffect
:
A side effect of composition that must run for any new unique value of [key1] and must be reversed or cleaned up if [key1] changes or if the [DisposableEffect] leaves the composition.
jean
02/28/2023, 9:22 AM