I want to request the Schedule Exact Alarms permission:
fun GrantExactAlarmsButton () {
val context = LocalContext.current
if (!canUseExactAlarms(context)) {
Button(
onClick = {
if (!canUseExactAlarms(context)) {
val intent = Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM).apply {
data = "package:${context.packageName}".toUri()
}
context.startActivity(intent)
}
}
) {
Text(text="Enable Exact Alarms!")
}
}
}
Except, I want this code to be in a sort of event listener.
I want to run some other code that depends on this permission, ONLY when context.startActivity returns.
I have thought about using an Activity Result, but I don't know how to use it for this.
Any ideas?