Ich möchte gerne meine aktuelle GPS-Position auf Knopfdruck anzeigen lassen. Später möchte ich die Position in einer Karte anzeigen.
Sub Button4_Click
Dim Location1 As Location
Dim LabelLat As Label
Dim labellon As Label
GPS1.Start(0, 0) 'Listen to GPS with no filters.
LabelLat.Text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
labellon.Text = "Lon = " & Location1.ConvertToMinutes(Location1.Longitude)
End Sub
Auf meinem S3 herhalte ich die Fehlermeldung: An error has occurred in sub:main_button4_click(java line:260) ... Object should first be initialzed (location).
Wie bekomme ich raus was mir die Fehlermeldung sagen soll.
Location ist doch ein Objekt (oder eine Eigenschaft?) in der SUB GPS_LocationChanged (Location1 AsLocation) wird location1 bei jeder Änderung übergeben. Ich möcht aber die Position einmalig haben.
M. E. ist Dein Fehler, dass Du Location1 dim'st.
Die Fehlermeldung besagt, dass Du mit Location1 arbeitest, obwohl diese Variable nicht initialisiert ist. Stimmt ja auch. Du DIM'st sie, aber anschließend wird sie verwendet, ohne gefüllt oder initialisiert zu sein...
Hallo
Wie gesagt, möchte ich auf einen Button drücken und einmalig die Position haben.
Sub Process_Globals
Dim GPS1 As GPS
End Sub
Sub Globals
Dim LabelLat As Label
Dim labellon As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
' Auf Main befindet sich der Button und die beiden Label
Activity.LoadLayout("Main")
If FirstTime Then
GPS1.Initialize("GPS")
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GPS_LocationChanged (Location1 As Location)
LabelLat.Text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
labellon.Text = "Lon = " & Location1.ConvertToMinutes(Location1.Longitude)
End Sub
Sub Button4_Click
GPS1.Start(0, 0)
End Sub
Wann wird GPS_LocationChanged aufgerufen? Selber aufrufen kann ich das ja nicht.
MfG Tudorf