Skip to content

Commit 662861c

Browse files
Cleanup unused handler
1 parent 74efa36 commit 662861c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

android/src/main/kotlin/com/icapps/background_location_tracker/service/LocationUpdatesService.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ internal class LocationUpdatesService : Service() {
4949
* Callback for changes in location.
5050
*/
5151
private var locationCallback: LocationCallback? = null
52-
private var serviceHandler: Handler? = null
5352

5453
private var wakeLock: PowerManager.WakeLock? = null
5554

@@ -70,9 +69,6 @@ internal class LocationUpdatesService : Service() {
7069
wakeLock = (getSystemService(Context.POWER_SERVICE) as PowerManager).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "mijnmooiestraat:location_updates")
7170
createLocationRequest()
7271
getLastLocation()
73-
val handlerThread = HandlerThread(TAG)
74-
handlerThread.start()
75-
serviceHandler = Handler(handlerThread.looper)
7672

7773
if (SharedPrefsUtil.isTracking(this)) {
7874
startTracking()
@@ -81,14 +77,17 @@ internal class LocationUpdatesService : Service() {
8177

8278
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
8379
Logger.debug(TAG, "Service started")
84-
val startedFromNotification = intent?.getBooleanExtra(EXTRA_STARTED_FROM_NOTIFICATION,
85-
false) ?: false
80+
val startedFromNotification = intent?.getBooleanExtra(
81+
EXTRA_STARTED_FROM_NOTIFICATION,
82+
false
83+
) ?: false
8684

8785
// We got here because the user decided to remove location updates from the notification.
8886
if (startedFromNotification) {
8987
stopTracking()
9088
stopSelf()
9189
}
90+
9291
// Tells the system to try to recreate the service after it has been killed.
9392
return START_STICKY
9493
}
@@ -136,7 +135,6 @@ internal class LocationUpdatesService : Service() {
136135

137136
override fun onDestroy() {
138137
Logger.debug(TAG, "Destroy")
139-
serviceHandler!!.removeCallbacksAndMessages(null)
140138
if (wakeLock?.isHeld == true) {
141139
wakeLock?.release()
142140
}

0 commit comments

Comments
 (0)