Android Programming Press on the image to return to the main documentation page.

GPS

The GPS library allows you to get information from the phone's GPS device.
See the
GPS tutorial for more information about this library.

List of types:

GPS
GPSSatellite
Location

GPS

The main object that raises the GPS events.
Note that this library requires Android 2.0 or above.

Permissions:

android.permission.ACCESS_FINE_LOCATION

Events:

LocationChanged (Location1 As Location)
UserEnabled (Enabled As Boolean)
GpsStatus (Satellites As List)
NMEA (TimeStamp As Long, Sentence As String)

Members:


  GPSEnabled As Boolean [read only]

  Initialize (EventName As String)

  IsInitialized As Boolean

  LocationSettingsIntent As android.content.Intent [read only]

  Start (MinimumTime As Long, MinimumDistance As Float)

  Stop

Members description:

GPSEnabled As Boolean [read only]
Tests whether the user has enabled the GPS.
Initialize (EventName As String)
IsInitialized As Boolean
LocationSettingsIntent As android.content.Intent [read only]
Returns the intent that is used to show the global locations settings.
Example:
If GPS1.GPSEnabled = False Then StartActivity(GPS1.LocationSettingsIntent)
Start (MinimumTime As Long, MinimumDistance As Float)
Starts listening for events.
MinimumTime - The shortest period (measured in milliseconds) between events. Pass 0 for highest frequency.
MinimumDistance - The shortest change in distance (measured in meters) for which to raise events. Pass 0 for highest frequency.
Stop
Stops listening to the GPS. You will usually want to call Stop inside Sub Activity_Pause.

GPSSatellite

The GPSSatellite object holds various information about a GPS satellite. A List with the available satellites is passed to the GpsStatus event.

Events:

None

Members:


  Azimuth As Float [read only]

  Elevation As Float [read only]

  IsInitialized As Boolean

  Prn As Int [read only]

  Snr As Float [read only]

  UsedInFix As Boolean [read only]

Members description:

Azimuth As Float [read only]
Returns the satellite azimuth in degrees (0 - 360).
Elevation As Float [read only]
Returns the satellite elevation in degrees (0 - 90).
IsInitialized As Boolean
Prn As Int [read only]
Returns the PRN (pseudo-random number) for the satellite.
Snr As Float [read only]
Returns the signal to noise ratio for the satellite.
UsedInFix As Boolean [read only]
Tests whether this satellite was used to calculate the most recent fix.

Location

A Location object holds various information about a specific GPS fix.
In most cases you will work with locations that are passed to the GPS LocationChanged event.
The location object can also be used to calculate distance and bearing to other locations.

Events:

None

Members:


  Accuracy As Float

  AccuracyValid As Boolean [read only]

  Altitude As Double

  AltitudeValid As Boolean [read only]

  Bearing As Float

  BearingTo (TargetLocation As android.location.Location) As Float

  BearingValid As Boolean [read only]

  ConvertToMinutes (Coordinate As Double) As String

  ConvertToSeconds (Coordinate As Double) As String

  DistanceTo (TargetLocation As android.location.Location) As Float

  Initialize

  Initialize2 (Latitude As String, Longitude As String)

  IsInitialized As Boolean

  Latitude As Double

  Longitude As Double

  Speed As Float

  SpeedValid As Boolean [read only]

  Time As Long

Members description:

Accuracy As Float
Gets or sets the fix accuracy (meters).
AccuracyValid As Boolean [read only]
Returns true if the fix includes accuracy value.
Altitude As Double
Gets or sets the fix altitude (meters).
AltitudeValid As Boolean [read only]
Returns true if the fix includes altitude value.
Bearing As Float
Gets or sets the fix bearing East of true North.
BearingTo (TargetLocation As android.location.Location) As Float
Returns the bearing to the given location.
BearingValid As Boolean [read only]
Returns true if the fix includes bearing value.
ConvertToMinutes (Coordinate As Double) As String
Converts the given coordinate to a string formatted with the following format:
[+-]DDD:MM.MMMMM (Minute = 1 / 60 of a degree)
ConvertToSeconds (Coordinate As Double) As String
Converts the given coordinate to a string formatted with the following format:
[+-]DDD:MM:SS.SSSSS (Minute = 1 / 60 of a degree, Second = 1 / 3600 of a degree)
DistanceTo (TargetLocation As android.location.Location) As Float
Returns the distance to the given location, measured in meters.
Initialize
Initializes an empty location object.
Initialize2 (Latitude As String, Longitude As String)
Initializes the location object with the given Latitude and Longitude.
Values can be formatted in any of the three formats:
Degrees: [+-]DDD.DDDDD
Minutes: [+-]DDD:MM.MMMMM (Minute = 1 / 60 of a degree)
Seconds: [+-]DDD:MM:SS.SSSSS (Second = 1 / 3600 of a degree)
Example:
Dim L1 As Location
L1.Initialize2("45:30:30", "45:20:15")
IsInitialized As Boolean
Latitude As Double
Gets or sets the fix latitude (degrees from -90 (South) to 90 (North)).
Longitude As Double
Gets or sets the fix longitude (degrees from -180 to 180, positive values represent the eastern hemisphere).
Speed As Float
Gets or sets the fix speed (meters / second).
SpeedValid As Boolean [read only]
Returns true if the fix includes speed value.
Time As Long
Gets or sets the fix time.
Top