Created
December 9, 2011 21:11
-
-
Save onlyangel/1453311 to your computer and use it in GitHub Desktop.
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
// AndroidManifest.xml must have the following permission: | |
// <uses-permission | |
// android:name="android.permission.ACCESS_FINE_LOCATION"/> | |
LocationManager locationManager = | |
(LocationManager) getSystemService(Context.LOCATION_SERVICE); | |
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, | |
0, new LocationListener() { | |
public void onStatusChanged(String provider, int status, | |
Bundle extras) { | |
// called when the provider status changes. Possible | |
// status: OUT_OF_SERVICE, TEMPORARILY_UNAVAILABLE or | |
// AVAILABLE. | |
} | |
public void onProviderEnabled(String provider) { | |
// called when the provider is enabled by the user | |
} | |
public void onProviderDisabled(String provider) { | |
// called when the provider is disabled by the user, if | |
// it's already disabled, it's called immediately after | |
// requestLocationUpdates | |
} | |
public void onLocationChanged(Location location) { | |
double latitute = location.getLatitude(); | |
double longitude = location.getLongitude(); | |
// do whatever you want with the coordinates | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment