List of usage examples for android.location Location getLongitude
public double getLongitude()
From source file:Main.java
public static String locationToString(Location location) { return "(" + location.getLatitude() + ";" + location.getLongitude() + ")" + " S=" + location.getSpeed() + " C=" + location.getBearing() + " A=" + location.getAccuracy(); }
From source file:Main.java
public static String getString(Location location) { double lat = location.getLatitude(); double lon = location.getLongitude(); return lat + "," + lon; }
From source file:Main.java
public static void setVivaCurrentLocation(Context context, Location location) { try {//from ww w. j a va 2s. c o m String loc = location.getLatitude() + "," + location.getLongitude(); getPreferences(context).edit().putString(Viva_Current_Location, loc).apply(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static String getLocation(Context context) { LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); String provider = LocationManager.NETWORK_PROVIDER; Location location = locationManager.getLastKnownLocation(provider); return location.getLatitude() + ":" + location.getLongitude(); }
From source file:Main.java
/** * Returns declination in degrees at given location * /*from w w w.j a v a 2 s . c om*/ * @param location * @return Declination in degrees */ public static float getDeclinationAt(Location location) { return getDeclinationAt((float) location.getLatitude(), (float) location.getLongitude(), (float) location.getAltitude()); }
From source file:Main.java
public static String getLatLng(Location location) { if (location == null) return null; return location.getLatitude() + " " + location.getLongitude(); }
From source file:Main.java
/** * Computes the distance in kilometers between two points on Earth. * * @param p1 First point//from w w w . j ava2 s . c o m * @param p2 Second point * @return Distance between the two points in kilometers. */ public static double distanceKm(Location p1, Location p2) { double lat1 = p1.getLatitude(); double lon1 = p1.getLongitude(); double lat2 = p2.getLatitude(); double lon2 = p2.getLongitude(); return distanceKm(lat1, lon1, lat2, lon2); }
From source file:Main.java
/** * Computes the distance in meters between two points on Earth. * * @param p1 First point// ww w . jav a2s . c o m * @param p2 Second point * @return Distance between the two points in meters. */ public static double distance(Location p1, Location p2) { double lat1 = p1.getLatitude(); double lon1 = p1.getLongitude(); double lat2 = p2.getLatitude(); double lon2 = p2.getLongitude(); return distance(lat1, lon1, lat2, lon2); }
From source file:Main.java
/** * Computes the bearing in radians between two points on Earth. * * @param p1 First point//from www .j a va 2 s.c o m * @param p2 Second point * @return Bearing between the two points in radians. A value of 0 means due * north. */ public static double bearingRad(Location p1, Location p2) { double lat1 = p1.getLatitude(); double lon1 = p1.getLongitude(); double lat2 = p2.getLatitude(); double lon2 = p2.getLongitude(); return bearingRad(lat1, lon1, lat2, lon2); }
From source file:Main.java
public static double[] getLastKnownLocation(Activity a) { LocationManager locationManager = (LocationManager) a.getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); String provider = locationManager.getBestProvider(criteria, true); System.out.println("provider: " + provider); Location location = locationManager.getLastKnownLocation(provider); return new double[] { location.getLatitude(), location.getLongitude() }; }