Created
February 1, 2014 16:12
-
-
Save sirvon/8754348 to your computer and use it in GitHub Desktop.
geotrigger snippet - savelocation to sharedpreferences
This file contains hidden or 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
@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