Skip to content

Commit

Permalink
fix: Request the current location if lastKnownLocation is null (#3358)
Browse files Browse the repository at this point in the history
* fix: Request the current location if lastKnownLocation is null

* Fix code formatting

Added a space before if statement opening bracket as it made the build check "
Validate Android / KTLint (pull_request)" fail.

---------

Co-authored-by: Andrei Tofan <[email protected]>
Co-authored-by: Jonas <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2025
1 parent 0271e9e commit b687014
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class MetadataProvider(val context: Context) : LocationListener {
Log.i(TAG, "Start updating location...")
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, UPDATE_INTERVAL_MS, UPDATE_DISTANCE_M, this)
this.location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)

if (this.location == null) {
// Request the current location if lastKnownLocation is null
locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, this, null)
}
} else {
Log.i(TAG, "Stopping location updates...")
locationManager.removeUpdates(this)
Expand Down

0 comments on commit b687014

Please sign in to comment.