Android Tutorial GPS / GNSS tutorial

Status
Not open for further replies.
The GNSS library replaces the old GPS library. The GNSS library is available here: https://www.b4x.com/android/forum/threads/gnss-library-an-updated-gps-library.109110/#content


1741875843450.png


Using it is quite simple:
1. Checking whether location services are available. If not take the user to the settings.
2. Request permission.

If the purpose is to get the user location then the FusedLocationProvider might be a better option: https://www.b4x.com/android/forum/threads/fusedlocationprovider-resolution-dialog.111652/#content
 

Attachments

Last edited:
Location1.Bearing is the current direction (angle to the North) in degrees according to the previous location.
Location1.BearingTo(Location2) is the orientation (angle to the North) in degrees between the two locations.
Location1.DirectionTo(Location2) is the distance between the two locations in meters.
 
I am using the GPS features since my start with b4a and it works always fine.

Now, in a new app, my actual position is not correct, it shows IMHO the Provider location, even if i disable the GPS feature "Network provider or WLan position"

The GPS example also shows a wrong place (apporx. 30 km away from me) . i just copied the code from this TuT to my new app.
as it not works, i work through the Tutorial again, but i found nothing strange or so...its quite simple to use the GPS.

P.S.: the GPS example V 2.1 works correct !

Has anyone a suggestion ?
 
Last edited:
Yes.
but when i start an navigation to any point the starting point in GoogleMaps is the correct one
 
If it returns wrong results then there is a problem on your device.
But what can that be ?
i am using the pure normal GPS example...no settings(options anywhere ;-) for a "offset" or something like that
 
Is there a way to smooth out the GPS numbers.

I am running the GPS example and there numbers keep changing while I am not moving 42.xx 45.xx 39.xx (these are distance to numbers) Now I know there is a +- 1 meter variance.

But is there an algorithm that smooth this out? I tried storing X (5 / 10) samples and then averaging them but that did not help much.
 
On my problem there is no change.
One runs, the other not with the correct positions.

Are there several choices to initialize the GPS ?

As i can see, in the V2.1 sample there is no other init as in my own app - but it works
 
Try to find the median of the last 10 samples. It should be quite smooth.


I did a Median 5 and that helped a lot - will see if 10 is any better.
I also changed my sampling from Start(0, 0) to Start(500, .5) <-- which I believe should give every half meter changes?

With Start(0, 0) there is so much bouncing without moving (tablet on desk) why would the numbers fluctuate like this? Is this the government misleading data?
 
which I believe should give every half meter changes?
Yes.
The first parameter is the minimum time (milliseconds) between events and the second parameter is the minimum distance (meters).

With Start(0, 0) there is so much bouncing without moving (tablet on desk) why would the numbers fluctuate like this? Is this the government misleading data?
Hard to say. The GPS library just passes the data from the GPS driver.
 
I am using RandomAccessFile to ReadObject and WriteObject and now have included a Location object in my Type and this field is either not being written out or read in. When I read the file after writing it I get a Null value for the Location type

Could you verify that ReadObject and WriteObject are handling GPS Location objects correctly?

I have lots of other different types of objects (Strings, Lists, Booleans, etc) and they are all written and read properly

Code:
	Type  TGPSDisplay(DisplayAt As String, Coordinates As Location)

The type above is used as entries to a list

Thanks BobVal
 
I searched on the internet and i read about coordinates. so in gps tutorial is gps coordinates. i need to convert it to wgs84 (decimal degrees).
 
I've recently upgraded my dev platform to KitKat running on my Samsung Galaxy S3 and now I must turn off location services before running my app again from the IDE (otherwise I get an empty screen except for labels) The code I'm using is the GPS tutorial code found at the top of this forum. I don't know why this is and am wondering if anyone else is experiencing this.

Thanks
Kevin

UPDATE: It actually will eventually recover using the GPS Tutorial code but takes a really long time like perhaps 10 plus minutes? Is there any reset code sequence that I could use to force it to reset / recover faster?
 
Last edited:
Status
Not open for further replies.
Back
Top