In this lecture, we started describing how to implement a checkin application.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> in the AndroidManifest.xml (or ACCESS_COARSE_LOCATION, but why would you ask for only that permission?). dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.google.code.gson:gson:2.3.1' compile 'com.google.android.gms:play-services:7.0.0'} LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); /** * Listenes to the location, and gets the most precise recent location. */ LocationListener locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { // Do something with the location you receive. } @Override public void onStatusChanged(String provider, int status, Bundle extras) {} @Override public void onProviderEnabled(String provider) {} @Override public void onProviderDisabled(String provider) {} }; // Stops the location updates. LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationManager.removeUpdates(locationListener);Of course, we would all hope that all it takes is a call to OhGreatGoogle.gimmeLocation(howPreciseIneedIt); But by this point you hae already guessed it: if it looks trivial, then it's only a few dozen lines of code (and a few dozen pages of documentation). So here it goes: