Htc desire s turn on gps

gordon

Member
Licensed User
Longtime User
I am following the gps tutorial in Visual Basic for Android Tutorial June 11 pdf. I am using a htc desire s however I don't seem to be able to get the app to recognise that the gps is turned on on the phone. The app halts at these lines of code

If GPS1.GPSEnabled = False Then 'turn on your GPS
ToastMessageShow("Please enable the GPS device", True)
StartActivity(GPS1.LocationSettingsIntent)
Else

I check the phones settings and it tells me that gps is turned on (though no icon to that effect appears in the status bar at the top of the phone)

When I press the continue button on the phone I get the following message

An error has occurred in sub main_activity_resume(B$A line 64)
If GPS1.GPSenabled=False Then 'turn on your GPS
java.lang.NullPointerException
Continue?

Pressing yes to that prompt results in the app freezing.

The gps on the phone is working, I tested it with google maps, and that works ok, indeed when google maps is working I do get the gps icon in the status bar.

Please help.
 

gordon

Member
Licensed User
Longtime User
I'm pretty confident that I have followed the code in the tutorial precisely.

I have
B4X:
Dim GPS1 As GPS


and
B4X:
Sub Activity_Resume
If GPS1.GPSEnabled = False Then 'turn on your GPS
ToastMessageShow("Please enable the GPS device", True)
StartActivity(GPS1.LocationSettingsIntent)
Else
GPS1.Start(0,0)
End If
GPS1.Start(0,0)
Compass.StartListening("Orientation")
End Sub
 
Upvote 0
Top