Hey guys i am building a geolocation application.
The following is the code which i use to get latitude and longitude :-
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
android.location.Location loc = lm.getLastKnownLocation(lm.NETWORK_PROVIDER);
dataManager.setLatitude(Double.toString(loc.getLatitude()));
Log.d("LATITUDE", dataManager.getLatitude());
Well the above code seems to be working on HTC devices and Samsung devices.
But for some strange reason i can not get the latitude and longitude in LG Optimus S.
I am thrown NullPointerException
Any help would be appreciated
Thanks in advance
Most probably, this is not related to the device type. If you don’t have a cell network (e.g. pull out the SIM card), then loc will be null in your code.