Вот соответствующий код:
Код: Выделить всё
@Composable
fun App() {
val context = LocalContext.current
val locationManager = context.getSystemService(LocationManager::class.java)
Column {
var oneTimeCoords by remember { mutableStateOf("longitude, latitude") }
Text(oneTimeCoords)
Button(
onClick = {
// code to immediately retrieve the current location once to show in the above text.
}
) {
Text("Get current location")
}
}
}
Как я могу получить текущее местоположение только один раз, не используя API Google?
Подробнее здесь: https://stackoverflow.com/questions/798 ... -google-ap
Мобильная версия