Android Tutorial GPS tutorial

Status
Not open for further replies.

Stulish

Active Member
Licensed User
Longtime User

Erel,

do you have any examples of using the reflection library to get to the NMEA data??

Thanks

Stu
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
GF(33, 33, 100, DateTime.Now)

Sub GF(lat As Float, lon As Float, altitude As Float, time As Long)
   Dim r As Reflector
   r.Target = r.CreateObject2("android.hardware.GeomagneticField", _
      Array As Object(lat, lon, altitude, time), _
      Array As String("java.lang.float", "java.lang.float", "java.lang.float", "java.lang.long"))
   Dim declination As Float = r.RunMethod("getDeclination")
   Dim fieldStrength As Float = r.RunMethod("getFieldStrength")
   Dim x As Float = r.RunMethod("getX")
End Sub
It should be simple to call the other methods.
 

Stulish

Active Member
Licensed User
Longtime User
Thanks Erel,

is there an easy way to implement

GpsStatus.NmeaListener

This contains a method containing the NMEA String this is the data i am looking for and currently converting location information using the GPS library into, this would mean i do not need to format the data and could just pass it through.

Thanks

Stu
 
Last edited:

Stulish

Active Member
Licensed User
Longtime User
Thanks again Erel,

I wasn't sure if a reflector could be used to get this string. so i will look for the update in the future.

Stu
 

Stulish

Active Member
Licensed User
Longtime User
That is great Erel, i din't expect it to be done so quickly and the sentences are just what i was after.

:sign0098: i think Great Job (but the Smilies don't have that on the notice board so i settled for Good Job
 

micp

Member
Licensed User
Longtime User
No position found using the demo.

Hi, i am more then a begginner into programming and i tryed to run the exemple source code to learn how it's working but no position is found using it and all satelites are return a false value. What am i doing wrong?
 

konisek

Member
Licensed User
Longtime User
Sometimes, the application pops up with error message:

main_gps_locationchanged (B4A line: 143)
Label3.Text = NumberFormat(Location1.Altitude,1,0) 'nadm. vyska
java.lang.RuntimeException: Object should first be initialized (Label).


Sometimes it also occurs with lblLat and lblLon and then
java.lang.RuntimeException: Object should first be initialized (Location).

As it happens rarely only, I do not know what is wrong with the code. Any advice, pls?
 

JTmartins

Active Member
Licensed User
Longtime User
A dumb question ??

Hi Guys,

This may seem a dumb question, bit if GPS can not be enabled programmaticly, how comes that I have a widget to turn on and of the GPS & Wi-fi, etc in my phone, and works ok ?

Thanks.
 

RichardHirst

Member
Licensed User
Longtime User
Input GPS string to GPS Library

Hi Erel,

Is or would it be possible to read a GPS string from a file or external serial port and pass this to the GPS Library to parse.

I have seen someone has a GPS parse code base but was hoping to be able to use the standard library.

Great work, just started to play with the new Google Maps library too .. oh can you rotate a custom marker ?


Thanks

Richard.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is or would it be possible to read a GPS string from a file or external serial port and pass this to the GPS Library to parse.
No, it is not possible. The parsing is done in a lower level than this library.

oh can you rotate a custom marker ?
Currently it is not possible. You can use a different bitmap, though the actual point will still be the bottom - center of this bitmap.
 

bushfire

New Member
Licensed User
Longtime User
NMEA Sentences

Hi Erel,

Are the NMEA sentences returned dependent upon the type of android device, or set by b4a?

In particular, I'm looking for two NMEA sentences that are prefixed by GPGGA and GPVTG. I'm using a Samsung Galaxy S for my app and it seems to be only returning PGLOR, GPGSV, and GPGSA.

Cheers
 

tsteward

Well-Known Member
Licensed User
Longtime User
Using the GPS library I get the following returned:
Lat = -36:3.20404
Lon = 146:59.30533

Now still sitting in the same chair, in Evernote I create a note that records my current GPS as
-36.204040
146.305330

My app creates notes in evernote and I need the same format as Evernotes.
I have read this thread, possibly missed the info I need. But is there a way to convert from one the top pair of Lat Lon to the evernote type pair.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…