Hi All,
I am trying to set up a Georeferencing system, to determine the nearest of a set of known locations, or to save a new location. However I am running into a problem getting the GPS_LocationChanged event to fire (ie, it's not firing at all, so far as I can tell). I am running off a Sony Xperia Z (C6603), with Android 4.3, if that makes any difference. Also, Google Maps and other GPS reliant apps run fine.
I receive the message "GPS Activated", and the edittext's change to 'Searching'. However, it doesn't make it to the messages at the start of the GPS_LocationChanged event.
I have also set the GPS permission in the ManifestEditor:
Is this the correct way to set the permissions?
Is there something I have to do to load the AndroidManifest.xml in, or is it included in the compilation?
I have a feeling that I am missing something incredibly obvious, but have no idea what it might be...
Any help would be greatly appreciated.
Cheers,
Ben
I am trying to set up a Georeferencing system, to determine the nearest of a set of known locations, or to save a new location. However I am running into a problem getting the GPS_LocationChanged event to fire (ie, it's not firing at all, so far as I can tell). I am running off a Sony Xperia Z (C6603), with Android 4.3, if that makes any difference. Also, Google Maps and other GPS reliant apps run fine.
I receive the message "GPS Activated", and the edittext's change to 'Searching'. However, it doesn't make it to the messages at the start of the GPS_LocationChanged event.
B4X:
Sub Process_Globals
Dim GPS1 As GPS
End Sub
Sub Globals
Dim Txt_Site_Lat As EditText
Dim Txt_Site_Long As EditText
Dim Btn_Site_GetLoc As Button
Dim Result As Int
Dim CurrentLat As String
Dim CurrentLong As String
End Sub
Sub Btn_Site_GetLoc_Click
If GPS1.IsInitialized = False Then
GPS1.Initialize("")
End If
If GPS1.GPSEnabled = False Then
Result = Msgbox2("The GPS needs to be turned on in the phone settings to use this function.","Activate GPS?","Open GPS settings","","Don't open GPS settings",Null)
If Result = DialogResponse.POSITIVE Then
StartActivity(GPS1.LocationSettingsIntent)
Return
Else If Result = DialogResponse.NEGATIVE Then
Return
End If
Else If GPS1.GPSEnabled = True Then
GPS1.Start(0,0)
Log("GPS Activated")
Msgbox("GPS Activated","")
Txt_Site_Lat.Text = "Searching"
Txt_Site_Long.Text = "Searching"
End If
End Sub
Sub GPS_LocationChanged(Location1 As Location)
Msgbox("Congrats! Your GPS is working!","")
Msgbox("Latitude is " & Location1.Latitude,"")
Msgbox("Longitude is " & Location1.Longitude,"")
CurrentLat = Location1.Latitude
CurrentLong = Location1.Longitude
Txt_Site_Lat.Text = Location1.Latitude
Txt_Site_Long.Text = Location1.Longitude
GPS1.Stop
End Sub
I have also set the GPS permission in the ManifestEditor:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
'Add Permissions
AddPermission(android.permission.ACCESS_FINE_LOCATION)
'End Add Permissions
Is this the correct way to set the permissions?
Is there something I have to do to load the AndroidManifest.xml in, or is it included in the compilation?
I have a feeling that I am missing something incredibly obvious, but have no idea what it might be...
Any help would be greatly appreciated.
Cheers,
Ben