Get exact intermediate location point in background and calculate distance from start and end locations in Android

Similar questions may arise in this matter, but I need your thoughts and suggestions on some specific requirements.

Here is my need - We are developing one application that tracks the user's trip. The application will begin collecting this user's location in the background. When the user "Starts" his trip from the App.Background Service will receive seats based on the user's movement at a certain time. When the user “stops” his trip from the application, we calculate the distance traveled by the user using all the recorded locations (using the Google’s distance calculation API). The application works great in an ideal case. But the main task - In some scenarios, we cannot get the exact and exact location of the User. The scenarios that affect this - there is no Internet, data plan with 2g / 3g, some specific areas where GPS does not return accurate data, etc.

Incorrect lat-long data leads to incorrect trip distance and route. The main problem with the application.

Please can anyone suggest a better alternative / suggestion for this? PS - We tried GPS, Network, FusedLocationProvider.

EDIT 2 -

We implemented logic based on accuracy and distance. Closer to the points. And I just stumbled upon one useful api from Google that fixes some location points that are distracted from real roads. The publication here is for reference by others ...

Snap to Api Roads from Google

+7
android android-location android-fusedlocation android-gps
source share
3 answers

This is a difficult topic.

One consideration you should take. Android Oreo restricts background services and that what you want to achieve will not work.

I would do it (and this is a recommendation from goolge)

When someone starts a trip (the user knows about it), you should start an outgoing notification using the foreground function, no longer rely on background services. Check out the Get Started feature in the Google Fit app.

As for the lack of a signal or accurate GPS, well ... it's a geographic issue !, you can't do anything. Or maybe you can using LocationProvider.

FusedLocationProvider connects to every application that requests location updates.

Read this and see if it helps you.

https://developer.android.com/guide/topics/location/strategies.html

+2
source share

Try connecting GPS and accelerometer

If you find that the GPS has stopped working, turn on the accelerometer. If the GPS turns on again, calculate the distance again with it. This way you can get directions using GPS parts and accelerometers. The more GPS details, the more accurate the data.

+1
source share

How to get more accuracy with GPS_PROVIDER

Basically, if location accuracy is unacceptable, throw it away. The next one will be better.

+1
source share

All Articles