Sub gpsActive(Tim As Long, Dis As Float)
If GPS1 = Null Then
GPS1.Initialize("GPS")
tl.Initialize
else
If GPS1.GPSEnabled = False Then
ToastMessageShow("GPS disabilitato.", True)
StartActivity(GPS1.LocationSettingsIntent)
GPS1.Start(Tim,Dis)
End If
end sub
peggio, mi frizza il telefono ... messo sotto un try per non bloccare il device, ma non ne vuole sapere
B4X:
Sub gpsActive(Tim As Long, Dis As Float) As Boolean
If GPS1 = Null Then
GPS1.Initialize("GPS")
tl.Initialize
End If
Try
If GPS1.GPSEnabled = False Then
ToastMessageShow("GPS disabilitato.", True)
StartActivity(GPS1.LocationSettingsIntent)
GPS1.Start(Tim,Dis)
Return True
End If
Catch
ToastMessageShow("Error GPS " & LastException.Message , True)
Return False
End Try
End Sub
Lo provato sul mio emulatore e funziona.
C'è qualcos'altro.
Riesci a farlo girare su emulatore per prelevare i log ?
Attenzione il test( if gps=null) non funziona !!!!
Quando lo hai inizializzato devi poi fare il test:
B4X:
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
GPS1.Start(0, 0) 'Listen to GPS with no filters.
End If
Lo provato sul mio emulatore e funziona.
C'è qualcos'altro.
Riesci a farlo girare su emulatore per prelevare i log ?
Attenzione il test( if gps=null) non funziona !!!!
Quando lo hai inizializzato devi poi fare il test:
B4X:
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
GPS1.Start(0, 0) 'Listen to GPS with no filters.
End If
Questo codice nell'emulatore funziona, ovvio che sms non lo invia, ma i passaggi li fa.. ma non mi risponde mai il gps con coordinate fasulle, altra cosa come si può controolare se il GPS1.Start(Tim,Dis) e attivo...
B4X:
Sub gpsActive(Tim As Long, Dis As Float) As Boolean
' If GPS1 = Null Then
GPS1.Initialize("GPS")
tl.Initialize
' End If
Try
If GPS1.GPSEnabled = False Then
ToastMessageShow("GPS disabilitato.", True)
StartActivity(GPS1.LocationSettingsIntent)
GPS1.Start(Tim,Dis)
Return True
Else
GPS1.Start(Tim,Dis)
Return True
End If
Catch
ToastMessageShow("Error GPS " & LastException.Message , True)
Return False
End Try
End Sub
Forse risolto -<<<<<<<<<<<<<<< HO RISOLTO VA ALLA GRANDE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
B4X:
Sub gpsActive(Tim As Long, Dis As Float) As Boolean
' If GPS1 = Null Then
GPS1.Initialize("GPS")
tl.Initialize
' End If
Try
If GPS1.GPSEnabled = False Then
ToastMessageShow("GPS disabilitato.", True)
StartActivity(GPS1.LocationSettingsIntent)
GPS1.Start(Tim,Dis)
Return True
Else
GPS1.stop <<<<<<<<<<<<<< questo solo per disattivare e fare ripartire anche se trovo assurdo
GPS1.Start(Tim,Dis)
Return True
End If
Catch
ToastMessageShow("Error GPS " & LastException.Message , True)
Return False
End Try
End Sub
'nella global
Dim Initial As Boolean
'nel codice dove hai l'initialize
If Initial=False Then
GPS1.Initialize("GPS")
Initial=True
End If
'Nel codice dove hai if gps1.gpsebabled
If Initial=True Then
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
GPS1.Start(0, 0) 'Listen to GPS with no filters.
End If
End If