Skip to content

Instantly share code, notes, and snippets.

@gbrennon
Created November 26, 2014 17:31
Show Gist options
  • Save gbrennon/50b3a914103cf7044a05 to your computer and use it in GitHub Desktop.
Save gbrennon/50b3a914103cf7044a05 to your computer and use it in GitHub Desktop.
GPS Examepl
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
setContentView(R.layout.activity_gps);
latituteField = (TextView) findViewById(R.id.latitudeTextField);
longitudeField = (TextView) findViewById(R.id.longitudeTextField);
altitudeField = (TextView) findViewById(R.id.altitudeTextField);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
gps = new GPS(this);
gps.setContext(this);
GPS.setLocation(location);
GPS.setFields(latituteField, longitudeField, altitudeField);
GPS.showSettingsAlert(locationManager);
Toast.makeText(this,
GPS.getLatitude(), Toast.LENGTH_SHORT).show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment