locationmanager,getLatitude function

by CSUIDL PROGRAMMEr » Thu, 23 Oct 2008 19:31:57 GMT


Sponsored Links
 Hello,
I am a newbie android developer. I am trying to simulate gps
functionality in android sdk 1.0.

I am using location manager  to get getlatitude function.

 http://pastebin.com/m56feb30c 

I am loading a google kml  through my ddms.

I get a java null pointer exception.
What am i doing wrong here

Thanks

--~--~---------~--~----~------------~-------~--~----~



locationmanager,getLatitude function

by Mast3rpyr0 » Thu, 23 Oct 2008 21:19:09 GMT


 does getLastKnownLocation have a location to give yet? try running
maps first then run your app



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


locationmanager,getLatitude function

by nkijak » Thu, 23 Oct 2008 21:24:48 GMT


 Hello,

I updated your code on that site to be more "correct". You should
stick with the static variable instead of hardcoding the string "gps".

You get a null pointer because you have to provide a location first,
meaning run the KML, then you can call getLastKnownLocation. When the
emulator starts, without being given a coordinate, it has no last
location. So try running the KML then running your app.

If you are trying to get continuous updates of location you should
implement LocationListener instead.

Nick



--~--~---------~--~----~------------~-------~--~----~



locationmanager,getLatitude function

by CSUIDL PROGRAMMEr » Mon, 03 Nov 2008 12:26:17 GMT


 Hello nkijak,
I could not find your upated code.
Also, i tried running the maps, ( including kml file, manually sending
decimal) .But the Nullpointer exception exists.
Is there anyone here who as got gps simulation working in android
here.
Thanks




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. getApplitcationContext() vs this vs ActivityClassName.this

Only use the application context if you need something that persists for the
lifetime of your process, and don't need to use it to do any UI (because it
is not associated with an activity UI session).

Generally if in doubt, pretend like it doesn't exist and don't use it.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~

2. JOIN Contacts.People and Contacts.People.Phones

Actually I guess the table to use is Contacts.Phones but the question
still stands.



--~--~---------~--~----~------------~-------~--~----~

3. getApplitcationContext() vs this vs ActivityClassName.this

4. Getting the contents of android.R.attr.listPreferredItemHeight (& other dimensional system resources?)

5. What permissions (if any) are needed for ...

6. out of memory error & getWallpaper

7. SMS Sent Listener