Skip to content

Commit 012679e

Browse files
cristanjordond
andauthored
Fix crash on no location found (#104)
Co-authored-by: Jordon de Hoog <[email protected]>
1 parent 4f1ffc3 commit 012679e

File tree

1 file changed

+4
-2
lines changed
  • compass-geolocation-mobile/src/androidMain/kotlin/dev/jordond/compass/geolocation/mobile/internal

1 file changed

+4
-2
lines changed

Diff for: compass-geolocation-mobile/src/androidMain/kotlin/dev/jordond/compass/geolocation/mobile/internal/LocationManager.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ internal class LocationManager(
5050
.addOnSuccessListener { location ->
5151
// Can actually be null. This most often happens when requesting a coarse location
5252
// and no other app recently successfully retrieved a location.
53+
// See https://developer.android.com/develop/sensors-and-location/location/retrieve-current#last-known
5354
if (location == null) {
54-
throw NotFoundException()
55+
continuation.resumeWithException(NotFoundException())
56+
} else {
57+
continuation.resume(location)
5558
}
56-
continuation.resume(location)
5759
}
5860
.addOnFailureListener { exception -> continuation.resumeWithException(exception) }
5961

0 commit comments

Comments
 (0)