@Override public void onLocationChanged(Location location) { GeomagneticField field = new GeomagneticField( (float)location.getLatitude(), (float)location.getLongitude(), (float)location.getAltitude(), System.currentTimeMillis() ); // getDeclination returns degrees mDeclination = field.getDeclination(); }
@Override public Uri insert( final Uri uri, final ContentValues oldvalues ){ SQLiteDatabase db = GAELdatabase.getWritableDatabase(); Uri result = null; Location loc = (Location)oldvalues.get("LOCATIONS"); ContentValues values = new ContentValues(); values.put("ALTITUDE", loc.getAltitude());//meters above sea level values.put("LATITUDE", loc.getLatitude()); values.put("LONGITUDE", loc.getLongitude()); long rowID = db.insert( "MyTABLE_NAME", "", values); db.close(); return result; }
@Override public Uri insert( final Uri uri, final ContentValues oldvalues ){ SQLiteDatabase db = GAELdatabase.getWritableDatabase(); Uri result = null; Location loc = (Location)oldvalues.get("LOCATIONS"); ContentValues values = new ContentValues(); values.put("ALTITUDE", loc.getAltitude());//meters above sea level values.put("LATITUDE", loc.getLatitude()); values.put("LONGITUDE", loc.getLongitude()); long rowID = db.insert( "MyTABLE_NAME", "", values); db.close(); return result; }
public class LocationChangedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String locationKey = LocationManager.KEY_LOCATION_CHANGED; if (intent.hasExtra(locationKey)) { Location location = (Location) intent.getExtras().get(locationKey); Log.d(TAG, "Got Location! Lat:" + location.getLatitude() + ", Lon:" + location.getLongitude() + ", Alt:" + location.getAltitude() + ", Acc:" + location.getAccuracy()); return; } } }
public void onLocationChanged(Location location) { double lon=location.getLongitude(); double lat=location.getLatitude(); double alt=location.getAltitude(); // Return altitude in meters, 0.0 if not available ... }
private void makeUseOfNewLocation(Location location) { try { architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy()); this.architectView.load("poi_1/index.html"); } catch (IOException e) { e.printStackTrace(); } }
float azimuth = event.values[0]; Location currentLoc = getHelper().getCurrentLocation(); if(currentLoc == null || cardinal == null || cardinal.getLocation() == null) { return; } try { GeomagneticField geoField = new GeomagneticField( Double.valueOf(currentLoc.getLatitude()).floatValue(), Double.valueOf(currentLoc.getLongitude()).floatValue(), Double.valueOf(currentLoc.getAltitude()).floatValue(), System.currentTimeMillis() ); float myBearing = currentLoc.bearingTo(cardinal.getLocation()); azimuth += geoField.getDeclination(); azimuth = (myBearing - azimuth) * -1; azimuth = normalizeDegree(azimuth); // compass.updateValues(-azimuth); } catch (Exception e) { e.printStackTrace(); } if(compass != null) { compass.setDirection(-azimuth); }
container.put("longitude", ""+gpsLocation.getLongitude()); container.put("accuracy", ""+gpsLocation.getAccuracy()); container.put("altitude", ""+gpsLocation.getAltitude()); container.put("provider", ""+gpsLocation.getProvider()); container.put("speed", ""+gpsLocation.getSpeed());
private class myLocationListener implements LocationListener{ @Override public void onLocationChanged(Location location) { if(location!=null){ locManager.removeUpdates(locListener); String longitude = "Longitude: " +location.getLongitude(); String latitude = "Latitude: " +location.getLatitude(); String altitiude = "Altitiude: " + location.getAltitude(); String cityName; Geocoder gcd = new Geocoder(getBaseContext(), Locale.getDefault()); public List<Address> addresses= gcd.getFromLocation (double latitude1, double longitude1, int maxResults) List<Address> addresses; try { addresses = gcd.getFromLocation(location.getLatitude(), location.getLongitude(), 1); if (addresses.size() > 0) System.out.println(addresses.get(0).getLocality()); cityName=addresses.get(0).getLocality(); } catch (IOException e) { e.printStackTrace(); } showLocation.setText("City Name: "+cityName+"+ "\n"+longitude + "\n" + latitude + "\n" + altitiude); progress.setVisibility(View.GONE); } }
@Override protected void onResume() { super.onResume(); this.architectView.onResume(); } @Override protected void onPause() { super.onPause(); this.architectView.onPause(); } @Override protected void onDestroy() { super.onDestroy(); this.architectView.onDestroy(); } //my own function private void makeUseOfNewLocation(Location location) { try { //MAKE SURE YOU CALL THIS architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy()); this.architectView.load("poi_1/index.html"); } catch (IOException e) { e.printStackTrace(); } }
Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setPowerRequirement(Criteria.POWER_LOW); LocationManager locManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if(locManager.getBestProvider(criteria,true) != null){ Location myLocation= locManager.getLastKnownLocation(locManager.getBestProvider(criteria, true)); String latitude = Double.toString(myLocation.getLatitude()); String longitude = Double.toString(myLocation.getLongitude()); String altitude = Double.toString(myLocation.getAltitude()); }
Double latitude = location.getLatitude(); Double longitude = location.getLongitude(); Double altitude = location.getAltitude(); Float accuracy = location.getAccuracy(); textView.setText("Latitude: " + latitude + "\n" + "Longitude: " + longitude+ "\n" + "Altitude: " + altitude + "\n" + "Accuracy: " + accuracy + "meters"+"\n" + "Location Counter: " + cnt);
Constants.LONGITUDE = location.getLongitude(); Constants.kAccuracy = location.getAccuracy(); Constants.ALTITUDE_VALUE = location.getAltitude();
Log.w("PROVIDER", String.valueOf(loc.getProvider())); Log.w("SPEED", String.valueOf(loc.getSpeed() + " m/s")); Log.w("ALTITUDE", String.valueOf(loc.getAltitude())); Log.w("BEARING", String.valueOf(loc.getBearing() + " degrees east of true north"));
alt = location.getAltitude(); speed = location.getSpeed();
alt = location.getAltitude(); speed = location.getSpeed();
double longitude = newLocation.getLongitude() + previousLocation.getLongitude(); longitude *= longitude; double altitude = newLocation.getAltitude() + previousLocation.getAltitude(); altitude *= altitude; GpsCalculator.this.totalDistance += Math.sqrt(latitude + longitude + altitude);
alt = location.getAltitude(); speed = location.getSpeed();
doubleFormat.format(location.getLatitude())); metric.setProperty("location:altitude", doubleFormat.format(location.getAltitude())); metric.setProperty("timestamp", StringUtils.formatDateTimeIso8601(location.getTime()));
Toast.makeText(MapsActivity.this,"Location :"+location.describeContents()+location.getSpeed()+"\n"+location.getAltitude()+"\n"+location.getLatitude()+"\n"+location.getLongitude()+"\n"+location.getProvider()+"\n"+location.getAccuracy(), Toast.LENGTH_SHORT).show();