M
M
Masteron2016-02-07 12:22:47
Java
Masteron, 2016-02-07 12:22:47

Android and location tracking?

Not long ago I came across the fact that location tracking can be implemented in different ways, for example: through LocationListener or Google play services. What is the best way to use if you need to know the approximate speed and coordinates of the client that will be sent further to the server? And if possible, throw a link to an article about it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Goryachkin, 2016-02-07
@Masteron

You can use either the standard requestLocationUpdate or the Fused Location Provider which is part of the Google play services api to get location. The advantage of the Fused Location Provider solution is that you do not have to look for the most accurate source of coordinates yourself, it will do it for you. If you run it with criteria to determine the most accurate location, then it will work according to the following principle:
1) If GPS is available and turned on, then GPS_PROVIDER is selected as the source.
2) If GPS is not available then NETWORK_PROVIDER is selected. In this case, the coordinates are determined using cell towers and WIFI.
3) If there is neither one nor the other, then PASSIVE_PROVIDER is used . Here the system tries to use any way to get at least some location, including when using the accelerometer. This provider is the least accurate.
So the Fused Location Provider includes all three and switches between them depending on the situation to get the most accurate location, and when using it, the battery drains more slowly. Its main disadvantages are that Google play services is required for its operation and that you will not be able to track which type of provider is currently being used.
As for the standard LocationManager , you will have to determine which provider to use and switch between them manually. In general, do everything by hand. The advantage is that you are in complete control of the entire process.
From myself, I’ll add that I used the Fused Location Provider and it works just fine, the main thing is that its version is 7 and higher, by 6 it gives a strong spread in coordinates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question