Android Question GPS reading

Discussion in 'Android Questions' started by kepler, Mar 31, 2015.

  1. kepler

    kepler Active Member Licensed User

    Good evening,

    I have no problem in using the GPS lib - actually is fantastic, and my congratulations to whoever made it.
    My only question is this: when, in the middle of the running app, the user simply goes out not pressing the back button in the android, even if the app already found the GPS coords, and then taps again in the app, the GPS values appear as the default I've defined - not the real ones that appeared the first time.
    This is not a lib problem - it's a User problem.
    Is there a way to clear all the cache or retrive the last good location values of the GPS?

    Kind regards,

    Kepler
     
  2. Harris

    Harris Well-Known Member Licensed User

    Seems you are initializing the GPS vars (which should be public) back to your default lat, lon values.

    I use a map to save the last known GPS values to a file and restore (read the map) when need be.
    For example, a user starts your app but GPS is not enabled. Read the last stored GPS map file, which contains lat and lon (along with anything else) and present a dialog allowing the user to accept the LAST KNOWN values - or - WAIT until GPS locks on a new valid location (more code).

    In my app, I need to have a valid lat, lon with each record written. There are times however when the GPS system can't resolve (initialize) a valid lat, lon before the user wishes to write a record (ie. login to my app). Simply read the map file and ask (display) if the last location is "good enough". In my situation, it often is because the user ended the app at the same location he/she is starting the app...

    A little logic goes a long way, however it took two years for it to dawn on me.... Ok, I am slow learner.

    Cheers.
     
    DonManfred likes this.
  3. kepler

    kepler Active Member Licensed User

    Hi,

    Thanks for the tip :)
    That seems the best way.

    Kind regards,

    Kepler
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice