@@ -49,7 +49,6 @@ internal class LocationUpdatesService : Service() {
49
49
* Callback for changes in location.
50
50
*/
51
51
private var locationCallback: LocationCallback ? = null
52
- private var serviceHandler: Handler ? = null
53
52
54
53
private var wakeLock: PowerManager .WakeLock ? = null
55
54
@@ -70,9 +69,6 @@ internal class LocationUpdatesService : Service() {
70
69
wakeLock = (getSystemService(Context .POWER_SERVICE ) as PowerManager ).newWakeLock(PowerManager .PARTIAL_WAKE_LOCK , " mijnmooiestraat:location_updates" )
71
70
createLocationRequest()
72
71
getLastLocation()
73
- val handlerThread = HandlerThread (TAG )
74
- handlerThread.start()
75
- serviceHandler = Handler (handlerThread.looper)
76
72
77
73
if (SharedPrefsUtil .isTracking(this )) {
78
74
startTracking()
@@ -81,14 +77,17 @@ internal class LocationUpdatesService : Service() {
81
77
82
78
override fun onStartCommand (intent : Intent ? , flags : Int , startId : Int ): Int {
83
79
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
86
84
87
85
// We got here because the user decided to remove location updates from the notification.
88
86
if (startedFromNotification) {
89
87
stopTracking()
90
88
stopSelf()
91
89
}
90
+
92
91
// Tells the system to try to recreate the service after it has been killed.
93
92
return START_STICKY
94
93
}
@@ -136,7 +135,6 @@ internal class LocationUpdatesService : Service() {
136
135
137
136
override fun onDestroy () {
138
137
Logger .debug(TAG , " Destroy" )
139
- serviceHandler!! .removeCallbacksAndMessages(null )
140
138
if (wakeLock?.isHeld == true ) {
141
139
wakeLock?.release()
142
140
}
0 commit comments