Android Question GPS on a Zebra TC21 (without GPS)

A customer has the Zebra TC21. It's a device without GPS.
The app is working on devices with GPS.


In the manifest we've added:
B4X:
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)

However when installed the app (which succeeds) the app keeps opening the "location" tab from the system settings. There is an option to enable the location. When enabling this and restart the app, then again this settings view is opened.
Removing the check "GPS1.GPSEnabled=false" then the app crashes on "GPS1.start(5000,0)" (try/catch doesn't work)

B4X:
        If GPS1.IsInitialized=True And Tracking=False Then
            If GPS1.GPSEnabled=False  Then
                ToastMessageShow(Language.Vertaal("Activeer de GPS."), True)
                StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen. Gets opened!? But "location" is set "on"
            End If
           
            If Tracking=True Or Globaal.CloseApp<>0 Then Return
            If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
                Globaal.DoSendLog("No permission")
                Return
            End If
            Try
                GPS1.Start(5000, 0) 'App crashes on this line -- try/catch doesnt work

Catch
End If

Any thoughts how to
1. prevent installing on devices without GPS
2. prevent opening the screen multiple times.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Solution
Top