Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.location.Location; import android.util.Pair; public class Main { /** * Get the latitude and longitude from the Location object returned by * Location Services. * * @param currentLocation A Location object containing the current location * @return The latitude and longitude of the current location, or null if no * location is available. */ public static Pair<Double, Double> getLatLng(Context context, Location currentLocation) { // If the location is valid if (currentLocation != null) { return new Pair<Double, Double>(currentLocation.getLatitude(), currentLocation.getLongitude()); } else { return null; } } }