Android Question GPS_UserEnabled

udg

Expert
Licensed User
Longtime User
Hi all,

I'm experimenting with the GPS library (v. 1.11, maye due to B4A v. 2.71) and came across to what appears a somewhat strange behaviour.

As per Erel definition (see GPS tutorial):
GPS_UserEnabled (Enabled As Boolean)
This event is raised whenever the user changes the status of the GPS device. It is also raised right after calling Start.


Now, what I found so far is that if the user disables the GPS service when we're in a GPS.Stop status then no GPS_UserEnabled event is raised.
I expected that event to be raised with Enabled = False in order to signal the app that GPS service is no more available.
The Enabled = False setting appears as expected when the user disables the GPS service when in the GPS.Start condition.

Summarizing it all in a (kind of) truth table, I have:

Starting condition Action UserEnabled event Enabled var
GPS_Service:eek:ff GPS_Service:eek:n called True
GPS_Service:eek:n + GPS.off GPS.Start called True
GPS_Service:eek:n + GPS.on GPS.Stop not called n.a.
GPS_Service:eek:n + GPS.on GPS_Service:eek:ff called False
GPS_Service:eek:n + GPS.off GPS_Service:eek:ff not called n.a.

where GPS_Service refers to what the user can enable/disable at the OS level, while GPS.on/GPS.off refers to start/stopping GPS reading fixes.

Don't know if it is possible at all (or eventually is already avalable in GPS library 1.20), but maybe two separate events, one for the availability of the service and the other for start/stop reading fixes could make it clearer the GPS usage.

Umberto
 

udg

Expert
Licensed User
Longtime User
Hi Erel,

what I find, in a way, "inconsistent" is the last scenario above:
GPS_service on + GPS.off and the user shutting down the service without notice to the app.
In my app I turn the GPS reading fixes on/off to be light on battery depletion.
So there are good chances that the user shuts down the GPS_service while in a stopped GPS reading phase.
Missing such an event, the app has no chance to visually set its own views to reflect the new scenario (currently I use a label showing: NO GPS-GPS Off-GPS On).
Surely at some point I could test for the GPS.Enabled boolean and then set my views accordingly, but this will not happen synchronously with the user action; for immediate action I should use a timer.. too complicated just to have a label updated.
If you don't see the need (or I can't be done) for a distinct event or for the GPS_UserEnabled called even when in stop phase, probably my best solution would be to revert back to your original tutorial example and just show a GPS Off/On label on the button used to start/stop readings and have there a test about the GPS_service availability.

Umberto
 
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
umberto hai trovato una soluzione per attivare il gps dalla tua applicazione acnhe se l'utente lo spegne dall'esterno?
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi BillyRudi,

please post in the Italian section so we can more easily discuss that point in that language without boring others here.

Umberto
 
Upvote 0
Top