Hi guys,

I am trying to get the latitude and longitude of the current location.
Let me clarify, I dont want to implement a listener that will create
an event when the location will be changed. I am trying to create an
app that will record the current location on a button click event.
Following is my code :

hdLocMgr = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
Log.w("LocationTracker", "The Location Manager is :
"+hdLocMgr.toString());
hdLocProvider = hdLocMgr.getBestProvider(hdCrit, true);
location = hdLocMgr.getLastKnownLocation(hdLocProvider);
dlat = location.getLatitude();
dlon = location.getLongitude();
Log.w("LocationTracker", "The value of Latitude is :
"+dlat.toString());

The code gives a RunTimeException (caused by NullPointerException as
stated in it).

Kindly help me out in that.

Regards,

Prayag

-- 
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