B4A Library LocationManagerEx library

Discussion in 'Additional libraries, classes and official updates' started by icefairy333, Oct 1, 2012.

  1. icefairy333

    icefairy333 Active Member Licensed User

    'Activity module
     Sub Process_Globals
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.
    End Sub
    Sub Globals
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
     Dim lmex As LocationManagerEx
    Dim btnGeoSet As Button
    Dim edthb As EditText
    Dim edtjd As EditText
    Dim edtwd As EditText
    End Sub
    Sub Activity_Create(FirstTime As Boolean)
    End Sub
    Sub lm_locationchanged(locArg As Location)
     End Sub
    Sub Activity_Resume
    End Sub
    Sub Activity_Pause (UserClosed As Boolean)
    End Sub
    Sub btnGeoSet_Click
    Dim l As Location
    End Sub

    Attached Files:

  2. warwound

    warwound Expert Licensed User

    Have you seen my xml2bb script?
    It makes easy work of creating library documentation from a library's xml file:

    Author: IceFairy333
    Version: 1.1
    • Location
      • BearingTo (TargetLocation As Location) As Float
      • ConvertToMinutes (Coordinate As Double) As String
      • ConvertToSeconds (Coordinate As Double) As String
      • DistanceTo (TargetLocation As Location) As Float
      • Initialize
      • Initialize2 (Latitude As String, Longitude As String)
      • IsInitialized As Boolean
      • Accuracy As Float
      • AccuracyValid As Boolean [read only]
      • Altitude As Double
      • AltitudeValid As Boolean [read only]
      • Bearing As Float
      • BearingValid As Boolean [read only]
      • Latitude As Double
      • Longitude As Double
      • Speed As Float
      • SpeedValid As Boolean [read only]
      • Time As Long
    • LocationManagerEx
      • locationchanged (locArg as Location As )
      • providerdisabled (providerStr as strin As )
      • providerenabled (providerStr as strin As )
      • statuschanged (providerStr as string As , statusflag as in As )
      • GeoSet (latitude As Double, longitude As Double, altitude As Double)
      • Initialize (EventName As String)
      • requestGPSLocation
      • requestMobileLocation
      • stopGPSListening
      • stopMobileListening
      • android.permission.ACCESS_COARSE_LOCATION
      • android.permission.ACCESS_FINE_LOCATION
      • android.permission.ACCESS_MOCK_LOCATION
      • android.permission.INTERNET

    I'll have a play with your library later.


    Last edited: Oct 14, 2012
  3. Informatix

    Informatix Expert Licensed User

    Cool !
  4. warwound

    warwound Expert Licensed User

    I just noticed it failing on a couple of bits of XML.
    I'll get them fixed!

  5. icefairy333

    icefairy333 Active Member Licensed User

    very good!
  6. fabio borges

    fabio borges Member Licensed User


    Could you include requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener) method in your lib?


  7. Dadeda

    Dadeda Member Licensed User

    how can i get the lat/long coordinates without using gps? only from wifi or 3g connection with your lib ?
  8. ddahan

    ddahan Member Licensed User

  9. 3fazeac

    3fazeac Member Licensed User

    I used this LocationManagerEx library to get my app working on a tablet that does not have GPS or 3G (but does have bluetooth).

    I feed the real GPS co-ordinates in from another phone using a GPS to bluetooth app and then pick up those co-ordinates on the tablet using a bluetooth to GPS app which displays the latitude and longitude just fine.

    My app runs and gets the latitude and longitude from the _LocationChanged callback. So everything is fine

    Dim lmex As LocationManagerEx

    Sub lm_locationchanged(Location1 As Location)
    Log("imported Lat " & Location1.Latitude)    ' this value supplied from other phone via the mock location mechanism
      Log("imported Long " & Location1.Longitude)
    Log("imported Alt " & Location1.Altitude)
    End Sub
    However, when I load the app on a device which supports GPS directly I want to use the standard GPS library and execute this code

    Dim GPS1 As GPS

    Sub GPS_LocationChanged(Location1 As Location)
    Log("GPS Lat " & Location1.Latitude)
    Log("GPS Long " & Location1.Longitude)
    Log("GPS Alt " & Location1.Altitude)
    End Sub
    but I get the following exception

    java.lang.RuntimeException: java.lang.Exception: Sub gps_locationchanged signature does not match expected signature.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:201)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
    at anywheresoftware.b4a.gps.GPS$1.onLocationChanged(GPS.java:65)
    at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:279)
    at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:208)

    It seems that the LocationManagerEx library has 'taken over' the message handlers even though no LocationManagerEx object is instantiated in the case where the GPS b4a library is used.

    It there a way around this problem? Currently I have to have two completely separate executables, one for a device with real GPS support and another if I need to use the 'mock' location library.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice