Android Question Reading GPS position in a service

Star-Dust

Expert
Licensed User
Longtime User
I found many examples to read GPS coordinates with the GPS Library, FusedLocationProvider, EsLocation2.

All examples Declare the GPS class (or FusionLocation, EsLocation) in the Starter module.
Here_For_GPS
Here_For_FusionLocationProvider
Here_For_EsLocation


I wonder if it's the best thing, since I would like to keep the service on.
Should you use another service model? Or is it OK as in the examples declaring it on Starter?

My need is to make a regular reading of the GPS position in the background

Thank's
 

Star-Dust

Expert
Licensed User
Longtime User
Thank Peter
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
But FusedLocation with SDK 23+ must ask for permissions.

Trying it this morning was not necessary, but I would not make mistakes
.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Yes, you need to add fine location to your manifest file. your app is for the play store, then you will be forced by Google to use SDK 26 by the end of this year anyway, so you might as well implement SDK 26 now.

Are you using an activity module too?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
We use an activity form.

The App, however, is not intended for Play Store is an app for an investigative agency. It is used to trace a device at any time

(See this post)
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Use FusedLocationProvider and a new service module, just use Starter to start the new service.
How precise is it?

With my tests today I see 1 wrong reading (of the order of 5 or 6 Neighborhood of error) every 6 readings.

So the journey seems inconsistent. Hi wrong something?
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
FLP is extremely precise as far as I'm concerned, I use it to manipulate data using my watch, my watch doesn't have GPS built-in so it relies on the FLP data that was collected by my other devices (GPS via my phone in most cases). If you believe that you're having location issues, you should just make things easier for yourself and just use the GPS library only.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I'll show you my problem, send me a screen
(Sorry if I'm a little off topic)

The red line is the one drawn by the library. The Green line represents a real path.
1.png


This is the minimum error, see other tracks are worse

2.png
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Have you tested the data manually yourself, that trace looks too erratic?

I did a cycle route tracker some years back and that trace was perfect.
What do you mean exactly?
I pass the data read to the OSMDroid library that traces the line. Do you think I should check with Google Map?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I did a test by replacing the FusedLocationProvider library with the GPS.
The measurements are accurate.

IMG_20180111_191951[1].png

So I think the problem is of the network that does not correctly localize.
But another problem arises, with GPS the costumes are very high and Android signals the App as high consumption. And it's a problem because it has to go unnoticed :(
 
Last edited:
Upvote 0

udg

Expert
Licensed User
Longtime User
You could wake-up your app at given intervals (15 minutes could be ok?), then acquire a lock, save data to your remote server, remove lock, go to sleep 'till next wake-up time. This will save a lot of battery.
With a time interval of 30 minutes I costantly am below 1mAh.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
You could wake-up your app at given intervals (15 minutes could be ok?), then acquire a lock, save data to your remote server, remove lock, go to sleep 'till next wake-up time. This will save a lot of battery.
With a time interval of 30 minutes I costantly am below 1mAh.
I am also thinking about this solution.

But I have to find a balance point so that the journey is continuous and the battery is not consumed.

There is another possibility, the EsLocation library that reads the position from both the network and the GPS.
 
Upvote 0
Top