简体   繁体   中英

How to get the current location as longitude and latitude value

I'm currently making a weather app and the latitude and longitude values could be used in the openweathermap API

So how do you get the user's current location by latitude and longitude values in kotlin?

I already tried various method on the internet but none of them worked for me..

This requires a lot of code, although most of it is for handling the Location permission. See here:

https://github.com/gavingt/SunCalculator/blob/master/app/src/main/java/com/gavinsappcreations/sunrisesunsettimes/ui/MainActivity.kt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM