Null is a valid return value from this method.  The documentation says
"If the provider is currently disabled, null is returned". Possibly
there other situations when there is no known last location.

http://developer.android.com/reference/android/location/LocationManager.html#getLastKnownLocation%28java.lang.String%29

Also you can use Google Maps app on this device/emulator with
"myLocation" to see if Google Maps has the same problem or not.

On Nov 21, 11:58 am, android_dev <[email protected]> wrote:
> Hi,
> i am also facing the same problem with android 1.6, i am sending
> coordinate through telnet but LastKnownLocation is returning null, m
> using android 1.6 eclipse window vista, am i doing anything wrong in
> Java code, can please send me java code. is it require any changes in
> menifest except permission. i have tried with all permissions.
> Thanks
>
> On Oct 24, 4:16 am, jotobjects <[email protected]> wrote:
>
> > Cool.  It seems like the best thing is to do both.  Call
> > getLastKnownLocation AND register a listener.  LastKnownLocation can
> > be null as documented so you have to expect that. And it can be
> > completely wrong if the the phone has been moved (you get off an
> > airplane and turn on your phone).  But you might not get any value for
> > a while from the listener (also as documented) so you have to expect
> > that also.  Quote from docs -
>
> > "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 are right about telnet.  I meant I'm runninggeofixON the
> > emulator after invoking telnet and the emulator itself is running
> > Linux - so that's wheregeofixruns in telnet (ALWAYS on Linux) even
> > if the O/S is windows or whatever.
>
> > On Oct 23, 3:50 pm, Brian Conrad <[email protected]> wrote:
>
> > > I solved the problem and have it working but not the way it originally
> > > worked.  Originally in one's code you code set up the location manager
> > > and then call from it getLastKnownLocation and get the coordinates.  
> > > These were what examples did when I first looked at GPS code.  That was
> > > what got broken and was apparently unintentional.  Instead I set up a
> > > location listener and nowgeofixworks and probably DDMS though I
> > > haven't tried that.  My thinking is that most people were writing
> > > applications where they would want updates while running.  Mine was just
> > > simple and needed the location at runtime or whenever the user wanted a
> > > recalculation.   So I'll instead set up the listener though we still
> > > only care when the application runs or is recalculated.  That  change is
> > > easy to implement.
>
> > > FYI, telnet also runs in the command line on Windows.  It's not unique
> > > to Linux.
>
> > > jotobjects wrote:
> > > > I just used Google Maps to "prove" thatgeofixworked and resulted in
> > > > the platform correctly knowing the location given bygeofix.  You
> > > > might want to try that too to prove thatgeofixdoes or doesn't work
> > > > in an application other than your own code.  That would be interesting
> > > > confirmation for you and is easy to do.
>
> > > > When I telnet into the emulator console and rungeofixas shown I am
> > > > using Linux on the emulator of course.
>
> > > > What problem has Android acknowledged regardinggeofix?  What is the
> > > > bug number?
>
> > > > On Oct 23, 12:44 pm, Brian Conrad <[email protected]> wrote:
>
> > > >> Are you running on Windows or Linux?  I'm running Ubuntu 8.04 and
> > > >> Eclipse.  Android acknowledgedgeofixwas broken in the 1.5 SDK.   I am
> > > >> usinggeofixto get the longitude and latitude only and not with Google
> > > >> Maps.  Everything is set in the manifest correctly too.   I have a 20%
> > > >> installed base which is about 600 users so I doubt if they would keep 
> > > >> it
> > > >> around if it wasn't working.
>
> > > >> I don't know anything about a rounding bug as I round anyway for use
> > > >> down to degrees and minutes.  One would think that DDMS would work when
> > > >> I have the app recalculate after sending coordinates manually.
>
> > > >> jotobjects wrote:
>
> > > >>>geofixworks for me with both DDMS and the emulator console.  Using
> > > >>> console this works -
>
> > > >>> telenet localhost 5554
> > > >>>geofix-117.24 32.883
>
> > > >>> This locates you in the University of California San Diego campus.  I
> > > >>> tried this with DDMS manualgeofixand it works there also.  My test
> > > >>> is using Google Maps "My Location" menu selection.  What is not
> > > >>> working withgeofixfor you?
>
> > > >>> Incidently I am now noticing that DDMS gives me the correct location.
> > > >>> But thegeofixcommand in the console exhibits the rounding problem
> > > >>> Auguste Lunang pointed to that is a couple of hundred feet off (which
> > > >>> is a problem for testing that depends on more accuracy).  Do you know
> > > >>> if there is a bug filed for the rounding problem?
>
> > > >>> On Oct 22, 5:06 pm, Brian Conrad <[email protected]> wrote:
>
> > > >>>> There is a bug filed forgeofix(not by me but by people who found it
> > > >>>> earlier).   I haven't filed one for DDMS until I'm sure I grok how it
> > > >>>> works as information still is very sketchy about this stuff and docs
> > > >>>> rather terse.
>
> > > >>>> My app calls getLastKnownLocation when it runs once.  It will call it
> > > >>>> again if the user selects Recalc.  Now under 1.1 when first run the
> > > >>>> emulator it would return what was set withgeofixor a default which I
> > > >>>> believe was Google's coordinates.   The DDMS method seems is 
> > > >>>> something
> > > >>>> one would use to emulate location updates.  With 1.5 and 1.6  when my
> > > >>>> app runs it gets a null back from getLastKnownLocation on the
> > > >>>> emulator.   So then I have DDMS send the coordinates to the emulator 
> > > >>>> (as
> > > >>>> instructed via the Dev Guide) then select Recalc I would think it 
> > > >>>> would
> > > >>>> have the new coordinates but it doesn't and just uses some fixed
> > > >>>> coordinates for demo purposes.  Apparently this app is working 
> > > >>>> normally
> > > >>>> on phones I would just like to have it working on the emulator so I
> > > >>>> could add and test similar functionality in other apps.
>
> > > >>>> jotobjects wrote:
>
> > > >>>>> Has there been a bug filed?
>
> > > >>>>> On Oct 22, 2:11 pm, Brian Conrad <[email protected]> wrote:
>
> > > >>>>>> Thanks. Yes, I know it's been a known issue because I've inquired a
> > > >>>>>> number of times after each update if it's been fixed.   The link 
> > > >>>>>> you
> > > >>>>>> posted goes back to 2008 but it was working fine in 1.1 last 
> > > >>>>>> spring.  
> > > >>>>>> It's not working with DDMS either.  I'll play around with it some 
> > > >>>>>> more
> > > >>>>>> to try to figure out why it is not working.
>
> > > >>>>>> Brian
>
> > > >>>>>> Auguste Lunang wrote:
>
> > > >>>>>>> Hi,This is a know issue. One of the discussions you can find here:
> > > >>>>>>>http://groups.google.com/group/android-beginners/browse_thread/thread...
> > > >>>>>>>  .
> > > >>>>>>> Try to use DDMS tofixyour GPS coordinates.
>
> > > >>>>>>> Hope it helps..
> > > >>>>>>> Auguste
>
> > > >>>>>>> 2009/10/22 Brian Conrad <[email protected]>
>
> > > >>>>>>>> I've tried thegeofixcommand to set  coordinates for a program I 
> > > >>>>>>>> wrote
> > > >>>>>>>> that provides the GPS coordinates.  This program worked fine in 
> > > >>>>>>>> 1.1.
> > > >>>>>>>> But thegeofixcommand got broken in 1.5 and appears to still have 
> > > >>>>>>>> not
> > > >>>>>>>> been fixed in 1.6?   When will it be fixed?
>
> > > >>>>>>>> Brian Conrad
> > > >>>>>>>> JyotishTools.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to