how to get current location in google map android

前端 未结 17 1935
长发绾君心
长发绾君心 2020-11-27 14:04

Actually my problem is I am not getting current location latitude and longitude I tried so many ways.I know that this question already asked in SO I tried that answers also

17条回答
  •  失恋的感觉
    2020-11-27 14:43

    FusedLocationApi has been Deprecated (Why Google always deprecated everything!)

    location: retrieve-current

    Here is the way to get it now:

    private lateinit var fusedLocationClient: FusedLocationProviderClient
    
    override fun onCreate(savedInstanceState: Bundle?) {
        // ...
    
        fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
    }
    

提交回复
热议问题