Drop location in tracker service (temp)'
This commit is contained in:
parent
318ae3d3cf
commit
5661b344a7
1 changed files with 7 additions and 1 deletions
|
@ -153,6 +153,7 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
app().shareLocationHelper.updateLocation(firstLocation)
|
app().shareLocationHelper.updateLocation(firstLocation)
|
||||||
|
|
||||||
// request location updates
|
// request location updates
|
||||||
|
/*
|
||||||
val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
||||||
try {
|
try {
|
||||||
locationManager.requestLocationUpdates(serviceOffProvider, 0, 0f, this@TelegramService)
|
locationManager.requestLocationUpdates(serviceOffProvider, 0, 0f, this@TelegramService)
|
||||||
|
@ -163,6 +164,7 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
Toast.makeText(this, R.string.gps_not_available, Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.gps_not_available, Toast.LENGTH_LONG).show()
|
||||||
log.debug("GPS location provider not available")
|
log.debug("GPS location provider not available")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startShareInfoUpdates() {
|
private fun startShareInfoUpdates() {
|
||||||
|
@ -222,6 +224,8 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
if (!AndroidUtils.isLocationPermissionAvailable(app)) {
|
if (!AndroidUtils.isLocationPermissionAvailable(app)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
var location: net.osmand.Location? = null
|
||||||
|
/*
|
||||||
val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
val service = app.getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
||||||
val ps = service.getProviders(true) ?: return null
|
val ps = service.getProviders(true) ?: return null
|
||||||
val providers = ArrayList(ps)
|
val providers = ArrayList(ps)
|
||||||
|
@ -233,24 +237,26 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
||||||
providers.add(0, providers.removeAt(passiveFirst))
|
providers.add(0, providers.removeAt(passiveFirst))
|
||||||
}
|
}
|
||||||
// find location
|
// find location
|
||||||
var location: net.osmand.Location? = null
|
|
||||||
for (provider in providers) {
|
for (provider in providers) {
|
||||||
val loc = convertLocation(service.getLastKnownLocation(provider))
|
val loc = convertLocation(service.getLastKnownLocation(provider))
|
||||||
if (loc != null && (location == null || loc.hasAccuracy() && loc.accuracy < location.accuracy)) {
|
if (loc != null && (location == null || loc.hasAccuracy() && loc.accuracy < location.accuracy)) {
|
||||||
location = loc
|
location = loc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return location
|
return location
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun removeLocationUpdates() {
|
private fun removeLocationUpdates() {
|
||||||
// remove updates
|
// remove updates
|
||||||
|
/*
|
||||||
val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
||||||
try {
|
try {
|
||||||
locationManager.removeUpdates(this)
|
locationManager.removeUpdates(this)
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
log.debug("Location service permission not granted")
|
log.debug("Location service permission not granted")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLocationChanged(l: Location?) {
|
override fun onLocationChanged(l: Location?) {
|
||||||
|
|
Loading…
Reference in a new issue