title: Preference On Change Listener
body: <p>I have read this helpful post :</p>
  
  <p><a href="https://stackoverflow.com/questions/2542938/sharedpreferences-onsharedpreferencechangelistener-not-being-called-consistently/3104265#3104265">SharedPreferences.onSharedPreferenceChangeListener not being called consistently</a></p>
  
  <p>However I am having no luck.  I am trying to create an OnSharedPreferenceChangeListener that runs in a service.  Everything is implemented correctly but the listener is not always triggered.</p>
  
  <pre><code>public MyServiceOne extends Service {
  
      public SharedPreferences mSharedPreferences;
  
      // Listener defined by anonymous inner class.
      public OnSharedPreferenceChangeListener mListener = new OnSharedPreferenceChangeListener() {        
  
          @Override
          public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
              Log.d("debug", "A preference has been changed");            
          }
      };
  
      @Override
      public void onCreate() {            
          mSharedPreferences = getSharedPreferences(MySharedPreferences.NAME, Context.MODE_PRIVATE);
          mSharedPreferences.registerOnSharedPreferenceChangeListener(mListener);
      }
  
      @Override   
      public void onDestroy() {
          super.onDestroy();
          mSharedPreferences.unregisterOnSharedPreferenceChangeListener(mListener);
      }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The problem stems from a fact I did not mention.  I am running two services and when shared preference changes are made in MyService2 nothing is triggered.  In the manifest I define the services to run in different processes.  Is there a way to make this work?</p>