Android Question GPS Problem

Good morning. I Have some problem using the GPs in Basic4A. First I want to tell that the GPS is working fine with other programs or also using some other programming language (as AppInventor). I tried as explained in documentation and also using a sample even in documentation. I have not any kind of error message, but only it doesnt works. Some suggestion, please ?
 
Here is the code, but I have take it from documentation od Basic4Android.
Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: GPS
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#End Region

Sub Process_Globals

End Sub

Sub Globals
Dim lblLon As Label
Dim lblLat As Label
Dim lblSpeed As Label
Dim lblSatellites As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
End Sub

Sub Activity_Resume
If Starter.GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.

End If
End Sub



Sub Activity_Pause (UserClosed As Boolean)
CallSub(Starter, "StopGPS")
End Sub

Public Sub GpsStatus (Satellites As List)
Dim sb As StringBuilder
sb.Initialize
sb.Append("Satellites:").Append(CRLF)
For i = 0 To Satellites.Size - 1
Dim Satellite As GPSSatellite = Satellites.Get(i)
sb.Append(CRLF).Append(Satellite.Prn).Append($" $1.2{Satellite.Snr}"$).Append(" ").Append(Satellite.UsedInFix)
sb.Append(" ").Append($" $1.2{Satellite.Azimuth}"$).Append($" $1.2{Satellite.Elevation}"$)
Next
lblSatellites.Text = sb.ToString
End Sub

Public Sub LocationChanged(Location1 As Location)
lblLat.Text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
lblLon.Text = "Lon = " & Location1.ConvertToMinutes(Location1.Longitude)
lblSpeed.Text = $"Speed = $1.2{Location1.Speed} m/s "$
End Sub
 

Attachments

  • GPS.zip
    8.9 KB · Views: 296
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You are using Api 23. So you MUST USE RUNTIMEPERMISSIONS Lib. See RuntimePermissions totorial.
I suggest to use Api 22 for now

Please note that it can not work if you do not START the GPS.

Find edited sample attached

Note that you need to DEINSTALL Your old App to run this... I changed your manifest to use SDK 22
 

Attachments

  • GPS.zip
    7.9 KB · Views: 301
Upvote 0
That was only to try because I tried to program using instructions od a tutorial found over youtube. That program also was not working without any error message.If you want I post the code of my program. I want say that if I try to program GPS using some otrher system (Like appinventor) it works fine....
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
That was only to try because I tried to program using instructions od a tutorial found over youtube. That program also was not working without any error message.If you want I post the code of my program. I want say that if I try to program GPS using some otrher system (Like appinventor) it works fine....
and...what mean ?
 
Upvote 0
Top