private void setServerPreferenceSummary(PreferenceFragment f, String s) {
      f.findPreference("connectionScreen")
          .setSummary(modesReadable[Preferences.getModeId()] + ": " + s);

      ((BaseAdapter) ((PreferenceScreen) f.findPreference("root")).getRootAdapter())
          .notifyDataSetChanged(); // Have to redraw the list to reflect summary change
    }
  private void init() {
    m2GCheckBoxPreference = (CheckBoxPreference) mFragment.findPreference(KEY_NETWORK_TYPE_2G);
    m3GCheckBoxPreference = (CheckBoxPreference) mFragment.findPreference(KEY_NETWORK_TYPE_3G);
    m4GCheckBoxPreference = (CheckBoxPreference) mFragment.findPreference(KEY_NETWORK_TYPE_4G);

    if (m2GCheckBoxPreference != null) {
      m2GCheckBoxPreference.setOnPreferenceChangeListener(
          (Preference.OnPreferenceChangeListener) mFragment);
    }
    if (m3GCheckBoxPreference != null) {
      m3GCheckBoxPreference.setOnPreferenceChangeListener(
          (Preference.OnPreferenceChangeListener) mFragment);
    }
    if (m4GCheckBoxPreference != null) {
      m4GCheckBoxPreference.setOnPreferenceChangeListener(
          (Preference.OnPreferenceChangeListener) mFragment);
    }

    Intent intent = getIntent();
    mSlotId = intent.getIntExtra(NetworkEditor.PLMN_SLOT, -1);
    mAct = intent.getIntExtra(NetworkEditor.PLMN_SERVICE, 0);

    PhoneLog.d(TAG, "init(): mSlotId = " + mSlotId + ", mAct = " + mAct);
    convertAct2Selections(mAct);

    if (!is4GSimCard(mSlotId)) {
      PhoneLog.d(
          TAG, "init(): the baseband of the sim card do not contain 4G. remove 4G CheckBox item.");
      PreferenceScreen prefSet = mFragment.getPreferenceScreen();
      prefSet.removePreference(m4GCheckBoxPreference);
    }
  }
  @Override
  public void onLoginSuccess(int socialNetworkID) {

    PreferenceFragment prefFrag =
        (PreferenceFragment) this.getFragmentManager().findFragmentByTag(FRAGMENT_TAG);

    if (FacebookSocialNetwork.ID == socialNetworkID) {
      // if event is from facebook
      CheckBoxPreference faceCheck =
          (CheckBoxPreference) prefFrag.findPreference(SettingsFragment.FACEBOOK_IS_ENABLED);
      faceCheck.setChecked(true);
    } else {
      // event is from twitter
      CheckBoxPreference twitterCheck =
          (CheckBoxPreference) prefFrag.findPreference(SettingsFragment.TWITTER_IS_ENABLED);
      twitterCheck.setChecked(true);
    }
  }
 public void test() throws InterruptedException {
   PreferenceFragment fragment =
       (PreferenceFragment)
           mActivity
               .getFragmentManager()
               .findFragmentByTag(MySettingsFragment.class.getSimpleName());
   CheckBoxPreference mUseExternalStorage =
       (CheckBoxPreference) fragment.findPreference(MyPreferences.KEY_USE_EXTERNAL_STORAGE_NEW);
   assertTrue(mUseExternalStorage != null);
   Thread.sleep(500);
   assertFalse("MyService is not available", MyServiceManager.isServiceAvailable());
 }