traccar / traccar-client-android

Traccar Client for Android
https://www.traccar.org/client
Apache License 2.0
663 stars 734 forks source link

FR: use most recent location for alarm #287

Open Abyss777 opened 7 years ago

Abyss777 commented 7 years ago

In case service is not started and other programs that uses location was started long time ago, Android update GPS location rather rarely. In that case when client send alarm it uses GPS location, that might be outdated. I think it is important to send most recent location with SOS alarm.

I would suggest select most recent location (if both available) in this piece of code https://github.com/tananaev/traccar-client-android/blob/master/app/src/main/java/org/traccar/client/ShortcutActivity.java#L109

tananaev commented 7 years ago

If location is enabled on the phone Android usually has reasonable up-to-date location, but I see your point.

Abyss777 commented 7 years ago

Android not always is able to get fresh GPS location. There are strange glasses in my office, no one device can fix GPS inside building. Because of that GPS fix on my phone will be outdated until I leave the office. If I click SOS shortcut, Traccar Client will send coordinates of some point of my trip to the work, but any navigation program shows my location very precisely. It is confusing.

tananaev commented 7 years ago

The problem is that if you select GPS or mixed provider, Traccar Client tries to get last known GPS location which can be old in case you are indoors. Maybe we should check time on the location and use network provider if GPS is too old.

Abyss777 commented 7 years ago

Yes, this option, can help to not sent too old location. Just curious... GPS location are always older than Network, or not, or depends how frequently applications ask for locations?

tananaev commented 7 years ago

Not really, I think it depends on various conditions. Network location is probably more commonly used by other apps, so it will be more recent. But if you run some GPS app (e.g. navigation), it's more likely that you will have GPS location more up-to-date than network.