Italian Widget e main.Sub

ivanomonti

Expert
Licensed User
Longtime User
Riscrivo così:
B4X:
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

fatto ma la bomba persiste qui

B4X:
 If GPS1.GPSEnabled = False Then
 

ivanomonti

Expert
Licensed User
Longtime User
Prova ad inizializzarlo sempre:
B4X:
GPS1.Initialize("GPS")
        tl.Initialize
elimina la condizione:
B4X:
If GPS1 = Null

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
 

arenaluigi

Well-Known Member
Licensed User
Longtime User
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
 

ivanomonti

Expert
Licensed User
Longtime User
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


Allora il problema sta nel device Galaxy s2 o nel suo os 4.0.3 ora provo nell'emulatore
 

ivanomonti

Expert
Licensed User
Longtime User
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
 

ivanomonti

Expert
Licensed User
Longtime User
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
 
Last edited:

arenaluigi

Well-Known Member
Licensed User
Longtime User
Prova così:
B4X:
'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
Ciao
 
Top