Get the latitude, in degrees.
All locations generated by the LocationManager will have a valid latitude.
1. In the MainActivity.java file, Get the Last Known Location
3. In the onCreate method, add the below line. This test and make sure the myLocation object is not null, and if not null, will get the latitude, in degrees and save it to a double variable named dblLatitude. Note: This will be the Last Known Latitude. It may not be the current latitude.
if (myLocation !=null) {
dblLatitude = myLocation.getLatitude();
}
3. In the onCreate method, add the below line. This test and make sure the myLocation object is not null, and if not null, will get the latitude, in degrees and save it to a double variable named dblLatitude. Note: This will be the Last Known Latitude. It may not be the current latitude.
if (myLocation !=null) {
dblLatitude = myLocation.getLatitude();
}
4. Compile and run!
Resources:
http://developer.android.com/reference/android/location/Location.html#getLatitude()
Resources:
http://developer.android.com/reference/android/location/Location.html#getLatitude()