demo:
outputlog
B4X:
'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)
Activity.LoadLayout("1")
lmex.Initialize("lm")
End Sub
Sub lm_locationchanged(locArg As Location)
Log(locArg.altitude)'海拔
Log(locArg.Longitude)'经度
Log(locArg.Latitude)'纬度
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnGeoSet_Click
Dim l As Location
l.Initialize
l.Altitude=edthb.Text
l.Longitude=edtjd.Text
l.Latitude=edtwd.Text
lmex.GeoSet(l.Latitude,l.Longitude,l.Altitude)
End Sub
outputlog
GeoSet:gpsLocation[mProvider=gps,mTime=0,mLatitude=111.0,mLongitude=111.0,mHasAltitude=true,mAltitude=55.0,mHasSpeed=false,mSpeed=0.0,mHasBearing=false,mBearing=0.0,mHasAccuracy=false,mAccuracy=0.0,mExtras=null]