androidlocationfusedlocationproviderapiandroid-fusedlocation

Android: Use FusedLocationProviderClient to get location once?


With FusedLocationProviderApi being deprecated, I'm having a hard time using FusedLocationProviderClient to get location of a user just once after a button click.


Solution

  • I'm having a hard time using FusedLocationProviderClient to get location of the user just once...

    FusedLocationProviderClient has the following methods

    where LocationRequest, in its turn, has the setNumUpdates (int numUpdates) method. By passing numUpdates = 1 you'll "get location of the user just once".