File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
location/src/main/kotlin/io/customer/location Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ internal class LocationLifecycleObserver(
2929 }
3030
3131 override fun onStop (owner : LifecycleOwner ) {
32- locationServices.cancelInFlightRequest()
32+ val wasCancelled = locationServices.cancelInFlightRequest()
33+ // If the GPS request was still in flight when we backgrounded,
34+ // allow onStart to retry on the next foreground entry.
35+ if (wasCancelled) {
36+ hasRequestedOnStart = false
37+ }
3338 }
3439}
Original file line number Diff line number Diff line change @@ -62,10 +62,14 @@ internal class LocationServicesImpl(
6262 /* *
6363 * Cancels any in-flight location request.
6464 * Called when the app enters background to avoid unnecessary GPS work.
65+ *
66+ * @return true if an active request was cancelled, false if nothing was in flight.
6567 */
66- internal fun cancelInFlightRequest () {
67- currentLocationJob?.cancel()
68+ internal fun cancelInFlightRequest (): Boolean {
69+ val job = currentLocationJob ? : return false
6870 currentLocationJob = null
71+ job.cancel()
72+ return true
6973 }
7074
7175 companion object {
You can’t perform that action at this time.
0 commit comments