get Geography by latitude and longitude - Android Map

Android examples for Map:Latitude Longitude

Description

get Geography by latitude and longitude

Demo Code


//package com.java2s;

import android.content.Context;

import android.location.Location;
import android.location.LocationManager;

public class Main {
    public static void getGeography(Context context, double latitude,
            double longitude) {

        LocationManager locationManager = (LocationManager) context
                .getSystemService(Context.LOCATION_SERVICE);
        if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            Location location = locationManager
                    .getLastKnownLocation(LocationManager.GPS_PROVIDER);
            if (location != null) {
                latitude = location.getLatitude(); 
                longitude = location.getLongitude();
            }//from w w  w  . j a v a2 s  .  com
        }
    }
}

Related Tutorials