Skip to content

Commit

Permalink
Fix crash for high accuracy service (#1492)
Browse files Browse the repository at this point in the history
* Fix crash for high accuracy service when onDestroy is called without even started the service

* Fix lint

* Really fix HighAccuracyLocationService crash
  • Loading branch information
chriss158 committed Apr 7, 2021
1 parent 4012860 commit d6b6f96
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -132,7 +132,7 @@ class HighAccuracyLocationService : Service() {
}
}

private lateinit var fusedLocationProviderClient: FusedLocationProviderClient
private var fusedLocationProviderClient: FusedLocationProviderClient? = null

override fun onCreate() {
super.onCreate()
Expand Down Expand Up @@ -163,7 +163,7 @@ class HighAccuracyLocationService : Service() {
override fun onDestroy() {
super.onDestroy()

fusedLocationProviderClient.removeLocationUpdates(getLocationUpdateIntent())
fusedLocationProviderClient?.removeLocationUpdates(getLocationUpdateIntent())

LAUNCHER.onServiceDestroy(this)

Expand All @@ -190,6 +190,6 @@ class HighAccuracyLocationService : Service() {
request.priority = LocationRequest.PRIORITY_HIGH_ACCURACY

fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this)
fusedLocationProviderClient.requestLocationUpdates(request, getLocationUpdateIntent())
fusedLocationProviderClient?.requestLocationUpdates(request, getLocationUpdateIntent())
}
}

0 comments on commit d6b6f96

Please sign in to comment.