You probably DO want to turn off GPS onPause() though - you don't want your app to drain the user's battery needlessly getting location updates when you're not doing anything with it. Just make sure to turn it back on in onResume() as necessary.
------------------------------------------------------------------------------------------------- TreKing - Chicago transit tracking app for Android-powered devices http://sites.google.com/site/rezmobileapps/treking On Thu, Dec 3, 2009 at 12:56 PM, stanlick <stanl...@gmail.com> wrote: > Thanks TreKing -- > > After pouring through my application last evening, I discovered one of > my tabs was turning *off* the radio in its onPause() method. Once I > remedied that, the app *does* now seem to behave like Google's stuff. > For those who may (pronounced WILL) suffer through this at some point, > watch the notification area closely! I failed to recognize the > satellite icon was disappearing when I clicked away from the tab! > Doh. > > Peace, > Scott > > On Dec 3, 8:59 am, TreKing <treking...@gmail.com> wrote: > > To reiterate what's been said, you only want to use > getLastKnownLocation() > > *ONCE*, at start up, to give you *something* to work with - a starting > > point. After that you should be relying only on the location provider > > updates for the most accurate location information. > > > > I would suggest you do what jotobjects suggests and log the different > > location values. I wouldn't be surprised if getLastKnownLocation() is > > different the whatever the location provider returns as the most current, > > since it's entirely possible that the system only updates the last known > > location once that last provider is unregistered. > > > > "It would be like the bank saying we can't tell you what your balance is > > now, but we can tell you what it was last Tuesday" > > > > It's more like "we can show your balance from Tuesday immediately, since > we > > have it already on hand, while we load up your most recent transactions". > > > > "It *must* be possible or the Google Nav and Maps wouldn't work either." > > > > Those apps work the same way. At least as far as I can tell, when > starting > > up Google Maps it generally jumps to the last place I had used GPS at > (ie, > > getLastKnownLocation()) and then pans to my current location as soon as > it > > has a fix. > > > > > ------------------------------------------------------------------------------------------------- > > TreKing - Chicago transit tracking app for Android-powered deviceshttp:// > sites.google.com/site/rezmobileapps/treking > > > > On Wed, Dec 2, 2009 at 7:18 PM, stanlick <stanl...@gmail.com> wrote: > > > When your app needs to show where *you are* -- where *you were* isn't > > > going to cut it. It would be like the bank saying we can't tell you > > > what your balance is now, but we can tell you what it was last > > > Tuesday. It *must* be possible or the Google Nav and Maps wouldn't > > > work either. I have it working much better now, but my confidence is > > > not real high. > > > > > Peace, > > > Scott > > > > > On Dec 2, 6:39 pm, Ken H <hunt1...@gmail.com> wrote: > > > > My understanding is getLastKnownLocation is used to give your app an > > > > immediate location since getting a good GPS fix can sometimes take up > > > > to a minute. This way your app would show *something* until a better > > > > position can be determined by initializing a provider, setting up > your > > > > time and distance update intervals, and giving that info to > > > > requestLocationUpdates for immediate updates. > > > > > > Ken > > > > > > On Dec 2, 2:19 pm, jotobjects <jotobje...@gmail.com> wrote: > > > > > > > requestLocationUpdates() docs say - > > > > > > > "It may take a while to receive the most recent location. If an > > > > > immediate location is required, applications may use the > > > > > getLastKnownLocation(String) method." > > > > > > > You could verify that getLastKnownLocation(providerName) returns > the > > > > > same Location as the argument to onLocationChanged() by logging > > > > > getLatitude(), getLongitude(), and getProvider() for both Location > > > > > values. If these values are different AND they are different than > > > > > what MyLocation shows then there are three different Location > values. > > > > > It would be interesting to know which one is right! > > > > > > > On Dec 2, 1:30 pm, stanlick <stanl...@gmail.com> wrote: > > > > > > > > Are you saying if the CB occurred, indicating a new location > "fix" > > > > > > that getLastKnownLocation would not also return this last know > > > > > > location? I think I tried using the the location local variable > > > > > > during one of my permutations and the net effect was the same. > Funny > > > > > > thing is, while the Android API location shows me several blocks > from > > > > > > where I am, the My Location button in Google Maps finds me > perfectly! > > > > > > I have checked all my criteria and it looks okay. ACCURACY_FINE > no > > > > > > concern for cost, etc. I just don't get it! I wish there was a > > > > > > criteria DO_IT_LIKE_GOOGLE_DOES! > > > > > > > > Sleepless in St. Louis, > > > > > > Scott > > > > > > > > On Dec 2, 3:14 pm, Jeffrey Blattman <jeffrey.blatt...@gmail.com> > > > > > > wrote: > > > > > > > > > LocationManager. requestLocationUpdates() > > > > > > > < > > >http://developer.android.com/reference/android/location/LocationManag.. > .> > > > > > > > LocationListener. onLocationChanged > > > > > > > < > > >http://developer.android.com/reference/android/location/LocationListe.. > > > .>(Location > > > > > > > < > > >http://developer.android.com/reference/android/location/Location.html> > > > > > > > location) > > > > > > > > > you are passed the location in the CB. no need to call > > > getLastKnown... > > > > > > > > > On 12/2/09 1:10 PM, stanlick wrote: > > > > > > > > > > I *am* using the listener loop and using getLastKnownLocation > > > from the > > > > > > > > locationManager inside the onLocationChanged() method. Is > this > > > not > > > > > > > > the correct pattern? > > > > > > > > > > On Dec 2, 2:31 pm, Lance Nanek<lna...@gmail.com> wrote: > > > > > > > > > >> Why are you using getLastKnownLocation if you want a fresh > fix? > > > The > > > > > > > >> documentation says it won't even start the location > provider. > > > Use > > > > > > > >> requestLocationUpdates. > > > > > > > > > >> On Dec 2, 2:53 pm, stanlick<stanl...@gmail.com> wrote: > > > > > > > > > >>> Didn't we put a man on the moon? It can't be done seems a > > > little lazy > > > > > > > >>> today! > > > > > > > > > >>> I have read all the posts about this topic and I understand > the > > > > > > > >>> arguments being made. However, I would like to know how > Google > > > Maps > > > > > > > >>> can return my *current* location yet while driving the same > > > stretch of > > > > > > > >>> road, the Android API often (not always) gives me a last > known > > > > > > > >>> location that was miles back. I need to be able to rely on > the > > > API to > > > > > > > >>> provide me with a *current location* and I have tried all > the > > > tricks > > > > > > > >>> being proposed here and elsewhere. Is there lower level > code > > > > > > > >>> someplace that could ping the phone's radio for a "fresh > fix?" > > > > > > > > > >>> If you have solved this riddle, I would be happy to pay for > > > your > > > > > > > >>> solution. > > > > > > > > > >>> Peace, > > > > > > > >>> Scott > > > > > > > > > -- > > > > > > > > > qr-gmail.png > > > > > > > < 1KViewDownload > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > android-developers@googlegroups.com > > > To unsubscribe from this group, send email to > > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com> > > > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en