@Override
  protected void onResume() {
    super.onResume();

    // Repopulate (which isn't too bad since it's cached in the settings
    // bluetooth manager
    addDevices();

    if (mScreenType == SCREEN_TYPE_SETTINGS) {
      mEnabler.resume();
      mDiscoverableEnabler.resume();
      mNamePreference.resume();
    }

    mLocalManager.registerCallback(this);

    mDeviceList.setProgress(mLocalManager.getBluetoothAdapter().isDiscovering());
    mLocalManager.startScanning(false);

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
    intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
    registerReceiver(mReceiver, intentFilter);
    mLocalManager.setForegroundActivity(this);
  }
  @Override
  protected void onPause() {
    super.onPause();

    mDevicePreferenceMap.clear();
    mDeviceList.removeAll();

    mLocalManager.setForegroundActivity(null);
    mDevicePreferenceMap.clear();
    mDeviceList.removeAll();
    unregisterReceiver(mReceiver);

    mLocalManager.unregisterCallback(this);
    if (mScreenType == SCREEN_TYPE_SETTINGS) {
      mNamePreference.pause();
      mDiscoverableEnabler.pause();
      mEnabler.pause();
    }
  }