Buongiorno,
sto usando la versione 6.80 con un programma scritto con la versione 6.50 e, con questa, funzionante.
Il programma una il GPS per ottenere Altitudine, LAT e LON secondo il seguente codice:
Sub Activity_Resume
If Starter.GPS1.GPSEnabled = False Then ' linea 829
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
End If
End Sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
If Permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
If Result Then CallSub(Starter, "StartGPS")
End If
End Sub
Public Sub LocationChanged(Location1 As Location)
alt=Location1.Altitude
LAT=Location1.Latitude
LON=Location1.Longitude
edtLAT.Text="Lat: " & NumberFormat(LAT,0,6) & " °"
edtLON.Text="Lon: " & NumberFormat(LON,0,6) & " °"
End Sub
Sub Activity_Pause (UserClosed As Boolean)
CallSub(Starter,"StopGPS")
End Sub
Nella sezione Starter, invece:
Public Sub StartGps
If gpsStarted=False Then
GPS1.Start(0,0)
gpsStarted=True
End If
End Sub
Public Sub StopGps
If gpsStarted=True Then
GPS1.Stop
gpsStarted=False
End If
End Sub
Sub GPS_LocationChanged (Location1 As Location)
If qlL="Main" Then
CallSub2(Main, "LocationChanged", Location1)
Else
CallSub2(Neve, "LocationChanged", Location1)
End If
End Sub
Con la versione 6.50 il codice funziona, con la 6.80 mi dà invece il seguente errore alla linea 829 all'avvio del programma:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 829 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.location.LocationManager.isProviderEnabled(java.lang.String)' on a null object reference
at anywheresoftware.b4a.gps.GPS.getGPSEnabled(GPS.java:149)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
at b4a.VentoNTC.main.afterFirstLayout(main.java:108)
at b4a.VentoNTC.main.access$000(main.java:17)
at b4a.VentoNTC.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5264)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:900)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
Qualche idea?
Grazie in anticipo.
Giorgio.
sto usando la versione 6.80 con un programma scritto con la versione 6.50 e, con questa, funzionante.
Il programma una il GPS per ottenere Altitudine, LAT e LON secondo il seguente codice:
Sub Activity_Resume
If Starter.GPS1.GPSEnabled = False Then ' linea 829
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
End If
End Sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
If Permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
If Result Then CallSub(Starter, "StartGPS")
End If
End Sub
Public Sub LocationChanged(Location1 As Location)
alt=Location1.Altitude
LAT=Location1.Latitude
LON=Location1.Longitude
edtLAT.Text="Lat: " & NumberFormat(LAT,0,6) & " °"
edtLON.Text="Lon: " & NumberFormat(LON,0,6) & " °"
End Sub
Sub Activity_Pause (UserClosed As Boolean)
CallSub(Starter,"StopGPS")
End Sub
Nella sezione Starter, invece:
Public Sub StartGps
If gpsStarted=False Then
GPS1.Start(0,0)
gpsStarted=True
End If
End Sub
Public Sub StopGps
If gpsStarted=True Then
GPS1.Stop
gpsStarted=False
End If
End Sub
Sub GPS_LocationChanged (Location1 As Location)
If qlL="Main" Then
CallSub2(Main, "LocationChanged", Location1)
Else
CallSub2(Neve, "LocationChanged", Location1)
End If
End Sub
Con la versione 6.50 il codice funziona, con la 6.80 mi dà invece il seguente errore alla linea 829 all'avvio del programma:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 829 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.location.LocationManager.isProviderEnabled(java.lang.String)' on a null object reference
at anywheresoftware.b4a.gps.GPS.getGPSEnabled(GPS.java:149)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
at b4a.VentoNTC.main.afterFirstLayout(main.java:108)
at b4a.VentoNTC.main.access$000(main.java:17)
at b4a.VentoNTC.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5264)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:900)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
Qualche idea?
Grazie in anticipo.
Giorgio.