Skip to content

Instantly share code, notes, and snippets.

@sirvon
Created February 1, 2014 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirvon/8754348 to your computer and use it in GitHub Desktop.
Save sirvon/8754348 to your computer and use it in GitHub Desktop.
geotrigger snippet - savelocation to sharedpreferences
@Override
public void onLocationUpdate(Location loc, boolean isOnDemand) {
// Called with the GeotriggerService obtains a new location update from
// Android's native location services. The isOnDemand parameter lets you
// determine if this location update was a result of calling
// GeotriggerService.requestOnDemandUpdate()
Toast.makeText(this, "Location Update Received!",
Toast.LENGTH_SHORT).show();
Log.d(TAG, String.format("Location update received: (%f, %f)",
loc.getLatitude(), loc.getLongitude()));
longitude = String.valueOf(loc.getLongitude());
latitude = String.valueOf(loc.getLatitude());
SharedPreferences sharedPrefs = getSharedPreferences("networkInfo", 0);
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString("networkLat", latitude).commit();
editor.putString("networkLong", longitude).commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment