Skip to content

Instantly share code, notes, and snippets.

@FireZenk
Last active April 22, 2022 09:51
Show Gist options
  • Save FireZenk/af56a09da26899fa5d22401a3f453031 to your computer and use it in GitHub Desktop.
Save FireZenk/af56a09da26899fa5d22401a3f453031 to your computer and use it in GitHub Desktop.
Open Location services activation settings from Compose
@Composable
fun ActivateLocationServices() {
val context = LocalContext.current
val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
if (!LocationManagerCompat.isLocationEnabled(lm))
context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
}
// Composable
ActivateLocationServices()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment