|
@@ -28,8 +28,9 @@ class TrackingService : Service() {
|
|
override fun onCreate() {
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
super.onCreate()
|
|
Log.i(mTag,"onCreate()")
|
|
Log.i(mTag,"onCreate()")
|
|
- requestLocationUpdates()
|
|
|
|
-
|
|
|
|
|
|
+ generateForegroundNotification()
|
|
|
|
+ startForeground(mNotificationId, notification)
|
|
|
|
+ Log.i(mTag,"Requested foreground service...")
|
|
}
|
|
}
|
|
|
|
|
|
private fun requestLocationUpdates() {
|
|
private fun requestLocationUpdates() {
|
|
@@ -38,6 +39,7 @@ class TrackingService : Service() {
|
|
mLocationRequest = LocationRequest.create().apply {
|
|
mLocationRequest = LocationRequest.create().apply {
|
|
interval = 2000
|
|
interval = 2000
|
|
fastestInterval = 2000
|
|
fastestInterval = 2000
|
|
|
|
+ //smallestDisplacement = 2.0f
|
|
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
|
|
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
|
|
}
|
|
}
|
|
|
|
|
|
@@ -46,7 +48,8 @@ class TrackingService : Service() {
|
|
locationResult ?: return
|
|
locationResult ?: return
|
|
for (location in locationResult.locations){
|
|
for (location in locationResult.locations){
|
|
counter += 1
|
|
counter += 1
|
|
- Log.i(mTag, "Got location: $counter")
|
|
|
|
|
|
+ val acc = location.accuracy
|
|
|
|
+ Log.i(mTag, "Got location: $counter $acc")
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -68,7 +71,7 @@ class TrackingService : Service() {
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
@Suppress("UNUSED_VARIABLE") val retVal: Int = super.onStartCommand(intent, flags, startId)
|
|
@Suppress("UNUSED_VARIABLE") val retVal: Int = super.onStartCommand(intent, flags, startId)
|
|
Log.i(mTag,"onStartCommand()")
|
|
Log.i(mTag,"onStartCommand()")
|
|
- generateForegroundNotification()
|
|
|
|
|
|
+ requestLocationUpdates()
|
|
return START_STICKY
|
|
return START_STICKY
|
|
}
|
|
}
|
|
|
|
|
|
@@ -113,7 +116,6 @@ class TrackingService : Service() {
|
|
}
|
|
}
|
|
builder.color = ContextCompat.getColor(this, R.color.purple_200)
|
|
builder.color = ContextCompat.getColor(this, R.color.purple_200)
|
|
builder.build().also { notification = it }
|
|
builder.build().also { notification = it }
|
|
- startForeground(mNotificationId, notification)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun onDestroy() {
|
|
override fun onDestroy() {
|