diff --git a/LocationUpdatesForegroundService/app/src/main/java/com/google/android/gms/location/sample/locationupdatesforegroundservice/MainActivity.java b/LocationUpdatesForegroundService/app/src/main/java/com/google/android/gms/location/sample/locationupdatesforegroundservice/MainActivity.java index 5244c7a7..ab5573af 100644 --- a/LocationUpdatesForegroundService/app/src/main/java/com/google/android/gms/location/sample/locationupdatesforegroundservice/MainActivity.java +++ b/LocationUpdatesForegroundService/app/src/main/java/com/google/android/gms/location/sample/locationupdatesforegroundservice/MainActivity.java @@ -135,8 +135,14 @@ protected void onCreate(Bundle savedInstanceState) { @Override protected void onStart() { super.onStart(); - PreferenceManager.getDefaultSharedPreferences(this) - .registerOnSharedPreferenceChangeListener(this); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + SharedPreferences.OnSharedPreferenceChangeListener listener = new SharedPreferences.OnSharedPreferenceChangeListener() { + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { + // Implementation + } + }; + prefs.registerOnSharedPreferenceChangeListener(listener); mRequestLocationUpdatesButton = (Button) findViewById(R.id.request_location_updates_button); mRemoveLocationUpdatesButton = (Button) findViewById(R.id.remove_location_updates_button);