title: How to reference or "find" a PreferenceActivity?
body: <p>I have legacy code which extends PreferenceActivity with a subclass called "Preferences". The PreferenceActivity is invoked as follows:</p>
  
  <pre><code>    Intent intent = new Intent(this, Preferences.class);
      this.startActivity(intent);
  </code></pre>
  
  <p>The OnSharedPreferenceChangeListener exists in a another fragment (not the PreferenceActivity subclass) but needs a reference to the PreferenceActivity in order to modify attributes of a custom preference/control similar to the following:</p>
  
  <pre><code>    pref = (CheckBoxPreference) prefActivity.findPreference(res.getString(R.string.keyAccount));
      pref.setSummary("something");
  </code></pre>
  
  <p>where "prefActivity" is the reference to the PreferenceActivity. Can anyone suggest how to save a reference to the PreferenceActivity when it is created or otherwise locate the PreferenceActivity when needed?</p>
  
  <p><strong>EDIT:</strong> Including the grossly oversimplified code to hopefully help show hierarchies and clarify.</p>
  
  <p>The FragmentActivity CPActivity instantiates CPFragment and on demand (a button press) creates an Intent to fire off a PreferenceActivity subclass (called "Preferences").</p>
  
  <pre><code>public class CPActivity extends FragmentActivity
  {
  public static CPActivity inst;
  private CPFragment mFragmentCP;
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
      super.onCreate(savedInstanceState);
      inst = this;
      mFragmentCP = new CPFragment();
      }
  
      public void onSettingsButtonPressed() {
      // Bring up the Preferences menu
      Intent intent = new Intent(this, Preferences.class);
      this.startActivity(intent);
      }
  }
  </code></pre>
  
  <p>CPFragment is our shared preference listener (among other things). It is in this code, where we'd like to modify a custom preference control/entry (that is, not the preference value itself, rather attributes on the preference control, e.g. a CheckBoxPreference). We'd like to do it here because this is where the pertinent data is calculated.</p>
  
  <pre><code>public class CPFragment extends Fragment implements OnSharedPreferenceChangeListener 
  {
      public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
      // In response to preference changes, we want to modify the PreferenceActivity controls.
      // So it seems we would need a reference to the PreferenceActivity subclass "Preferences
      }
  }
  </code></pre>
  
  <p>And finally, the PreferenceActivity subclass "Preferences" does little more than bring up the Settings view.</p>
  
  <pre><code>    public class Preferences extends PreferenceActivity
  {
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          addPreferencesFromResource(R.xml.preferences_cp);
      }
  }
  </code></pre>
  
  <p>As I mentioned, we'd prefer to be able to modify the Custom Preference in CPFragment (as opposed to the PreferenceActivity). Therefore I was looking for some way of locating the PreferenceActivity while responding as onSharedPreferenceChangeListener in CPFragment.</p>