@Override public void onLocationChanged(Location arg0) { myLocation.setLatitude(Double.toString(arg0.getLatitude())); myLocation.setLongitude(Double.toString(arg0.getLongitude())); myLocation.setTimestamp(arg0.getTime()); myLocation.setUserId(Secure.ANDROID_ID); if (new DateTime(arg0.getTime().minusMinutes(5) > new DateTime(oldTime)) postToRemote(myLocation); }
public void onLocationChanged(Location location) { Date dd=new Date(location.getTime()); Date ddd=new Date(System.currentTimeMillis()-(1000*60*15)); Log.e("", String.valueOf(location.getTime()+":"+System.currentTimeMillis()+":"+dd+":"+ddd)); if (dd.compareTo(ddd)==1?true:false) { got=true; latitude=String.valueOf(location.getLatitude()); longitude=String.valueOf(location.getLongitude());} }
String latestFixProvider = null; long time = 0; for(int i = 0; i < providers.size(); i++){ Location lastKnown = locationManager.getLastKnownLocation(providers.get(i)); if(lastKnown != null && lastKnown.getTime() > time){ latestFixProvider = providers.get(i); time = lastKnown.getTime(); } } String lastFixDate = getDate(time, "dd/MM/yyyy hh:mm:ss.SSS"); if (latestFixProvider != null) { Location loc = locationManager.getLastKnownLocation(latestFixProvider); if (loc != null) { TWlongitude.setText(Double.toString(loc.getLongitude())); TWlatitude.setText(Double.toString(loc.getLatitude())); } }
@Override public void onLocationChanged(Location location) { if (location != null) { pLong = location.getLongitude(); pLat = location.getLatitude(); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss", java.util.Locale.getDefault()); formatted = sdf.format(location.getTime()); //add code below: String jSONString= convertToJSON(pLong, pLat, formatted); sender.timer(jSONString); } }
public void onLocationChanged(Location location) { int lat = (int) (location.getLatitude() * 1E6); int lon = (int) (location.getLongitude() * 1E6); String tim = String.format("%d", location.getTime());}
this.latitude = location.getLatitude(); Date locDate = new Date(location.getTime()); DateFormat df = new SimpleDateFormat("z yyyy.MM.dd. HH:mm:ss"); df.setTimeZone(TimeZone.getTimeZone("GMT+1"));
private LocationRequest mlocationrequest; // location listener LocationListener loc_listener = new LocationListener() { @Override public void onLocationChanged(Location arg0) { if (arg0 != null) { lat = arg0.getLatitude(); lng = arg0.getLongitude(); tm = arg0.getTime(); } } };
@Override public void onLocationChanged(Location location) { if (location != null) { if (location.getProvider().equals(LocationManager.GPS_PROVIDER) && android.os.Build.VERSION.SDK_INT < 16) { Log.i("TEST", "DATE: " + TimeToDate.getDate(location.getTime(), "yyyy-MM-dd HH:mm:ss")); Log.i("TEST", "LAT: " + location.getLatitude()); Log.i("TEST", "LONG: " + location.getLongitude()); locationManager.removeUpdates(locationListener); new Handler().postDelayed(new Runnable() { @Override public void run() { locationManager.requestLocationUpdates(getProviderName(), minTime, minDistance, locationListener); } }, minTime); } ...
@Override public void onLocationChanged(Location loc) { loc.getLatitude(); loc.getLongitude(); latitude.setText(""+loc.getLatitude()); longitude.setText(""+loc.getLongitude()); time.setText(""+loc.getTime()); }
getLocation(Location location) { ......... String loc = "Lattitude: "+location.getLatitude()+" longi "+location.getLongitude()+" Accur "+location.getAccuracy()+" Time "+location.getTime() +" "+location.getProvider(); Log.i("Log",loc); Toast.makeText(MainActivity.this, loc, Toast.LENGTH_LONG).show(); }
intent.putExtra(TIMESTAMP, locationVal.getTime()); intent.putExtra(ALTITUDE,locationVal.getAltitude()); intent.putExtra(NUM_SATELLITES,0);/////////////****TEMP
values.put(COLUMN_LATITUDE, location.getLatitude()); values.put(COLUMN_LONGITUDE, location.getLongitude()); values.put(COLUMN_TIME, location.getTime()); values.put(COLUMN_SPEED, location.getSpeed()); values.put(COLUMN_DISTANCE_TO_LAST_LOC, location.distanceTo(lastLocation));
new LocationListener() { private Location mLastLocation; @Override public void onLocationChanged(Location pCurrentLocation) { //calcul manually speed double speed = 0; if (this.mLastLocation != null) speed = Math.sqrt( Math.pow(pCurrentLocation.getLongitude() - mLastLocation.getLongitude(), 2) + Math.pow(pCurrentLocation.getLatitude() - mLastLocation.getLatitude(), 2) ) / (pCurrentLocation.getTime() - this.mLastLocation.getTime()); //if there is speed from location if (pCurrentLocation.hasSpeed()) //get location speed speed = pCurrentLocation.getSpeed(); this.mLastLocation = pCurrentLocation; //////////// //DO WHAT YOU WANT WITH speed VARIABLE //////////// } @Override public void onStatusChanged(String s, int i, Bundle bundle) { } @Override public void onProviderEnabled(String s) { } @Override public void onProviderDisabled(String s) { } };
String altitiude = "Altitiude: " + location.getAltitude(); String accuracy = "Accuracy: " + location.getAccuracy(); String time = "Time: " + location.getTime();
private Location oldLocation; private float[] results; private ArrayList<float> speedList; //in oncreate: speedList = new ArrayList<Float>(); private void updateWithNewLocation(Location location) { String where = ""; results = new float[100]; //[100] means there can be 100 entries - decrease or increase the number depending on your output if (location != null) { double lng = location.getLongitude(); double lat = location.getLatitude(); float speed = location.getSpeed(); long time = location.getTime(); String timeString = getTimeString(time); speedList.add(speed); if(oldLocation != null){ Location.distanceBetween(oldLocation.getLatitude(), oldLocation.getLongitude(), lat, lng, results); } oldLocation = location;
doubleFormat.format(location.getAltitude())); metric.setProperty("timestamp", StringUtils.formatDateTimeIso8601(location.getTime())); metric.setProperty("distance:value", doubleFormat.format(distance)); metric.setProperty("distance:units", "km");
alt = location.getAltitude(); speed = location.getSpeed(); dateTime = location.getTime();
tv.setText("My current location is:\n" + txt); String msg = loc.getLongitude() + "\n" + loc.getLatitude() + "\n" + loc.getTime();
public class SampleNMEA extends Activity implements LocationListener, GpsStatus.Listener,GpsStatus.NmeaListener{ LocationManager lm; TextView output; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); output = (TextView)findViewById(R.id.out); lm = (LocationManager) getSystemService(LOCATION_SERVICE); lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000,10,this); final Location location=lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); output.append("\nBelow Data is about the your location:"); output.append("\n\n\nLatit:"+location.getLatitude()); output.append("\n\nLongitude:"+location.getLongitude()); output.append("\n\nTime: "+location.getTime()); //add listener here lm.AddNmeaListener(this); }