Created
November 26, 2014 17:31
-
-
Save gbrennon/50b3a914103cf7044a05 to your computer and use it in GitHub Desktop.
GPS Examepl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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