yayaa / LocationManager

Simplify getting user's location for Android
806 stars 187 forks source link

Hope to add an API to get last known location synchronously. #70

Closed fightyz closed 6 years ago

fightyz commented 6 years ago

Hope to add an api named Location getLastKnownLocation() in class LocationManager.

Thanks.

fightyz commented 6 years ago

I notice that the Google's LocationService calls getLastLocation() to get last known location only after the GoogleApiClient is connected. So this method is a asynchronous call. But the Android's getLastKnownLocation() is a synchronous call. But in most cases, I think the developers wish to get last known location synchronously. So I suggest that, the LocationManager return last known location immediately using Android's location service if GoogleApiClient has not been connected yet. But if GoogleApiClient is already connected, LocationManager returns the most recently location result between GoogleApiClient and Android location service, by comparing the Location's time.

yayaa commented 6 years ago

Could you tell me the usecase for this? Library already checks getLastKnownLocation anyway. It returns immediately that location if your requirements match, otherwise it requests location update.

Why do you need this to be synchronised?

Sorry for questioning but I would like to keep the library as simple as possible :) I don't wanna end up exposing every method that LocationManager for Android has, then this library will have no difference in complexity perspective :)

yayaa commented 6 years ago

Feel free to re-open this issue if you are still interested. Please also point a valid usecase, thanks!