@Override
 public void onPause() {
   super.onPause();
   if (mApplications != null) {
     mApplications.pause();
   }
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   mResetAppsHelper.onSaveInstanceState(outState);
   outState.putInt(EXTRA_SORT_ORDER, mSortOrder);
   outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
   outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries);
 }
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   if (mListType == LIST_TYPE_STORAGE) {
     FrameLayout pinnedHeader = (FrameLayout) mRootView.findViewById(R.id.pinned_header);
     AppHeader.createAppHeader(getActivity(), null, mVolumeName, null, pinnedHeader);
   }
 }
  @Override
  public void onDestroyView() {
    super.onDestroyView();

    if (mApplications != null) {
      mApplications.release();
    }
    mRootView = null;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    mApplicationsState = ApplicationsState.getInstance(getActivity().getApplication());

    Intent intent = getActivity().getIntent();
    Bundle args = getArguments();
    String className = args != null ? args.getString(EXTRA_CLASSNAME) : null;
    if (className == null) {
      className = intent.getComponent().getClassName();
    }
    if (className.equals(AllApplicationsActivity.class.getName())) {
      mShowSystem = true;
    } else if (className.equals(NotificationAppListActivity.class.getName())) {
      mListType = LIST_TYPE_NOTIFICATION;
      mNotifBackend = new NotificationBackend();
    } else if (className.equals(DomainsURLsAppListActivity.class.getName())) {
      mListType = LIST_TYPE_DOMAINS_URLS;
    } else if (className.equals(StorageUseActivity.class.getName())) {
      if (args != null && args.containsKey(EXTRA_VOLUME_UUID)) {
        mVolumeUuid = args.getString(EXTRA_VOLUME_UUID);
        mVolumeName = args.getString(EXTRA_VOLUME_NAME);
        mListType = LIST_TYPE_STORAGE;
      } else {
        // No volume selected, display a normal list, sorted by size.
        mListType = LIST_TYPE_MAIN;
      }
      mSortOrder = R.id.sort_order_size;
    } else if (className.equals(UsageAccessSettingsActivity.class.getName())) {
      mListType = LIST_TYPE_USAGE_ACCESS;
      getActivity().getActionBar().setTitle(R.string.usage_access_title);
    } else if (className.equals(HighPowerApplicationsActivity.class.getName())) {
      mListType = LIST_TYPE_HIGH_POWER;
      // Default to showing system.
      mShowSystem = true;
    } else if (className.equals(OverlaySettingsActivity.class.getName())) {
      mListType = LIST_TYPE_OVERLAY;
      getActivity().getActionBar().setTitle(R.string.system_alert_window_access_title);
    } else if (className.equals(WriteSettingsActivity.class.getName())) {
      mListType = LIST_TYPE_WRITE_SETTINGS;
      getActivity().getActionBar().setTitle(R.string.write_settings_title);
    } else {
      mListType = LIST_TYPE_MAIN;
    }
    mFilter = getDefaultFilter();

    if (savedInstanceState != null) {
      mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
      mShowSystem = savedInstanceState.getBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
    }

    mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);

    mResetAppsHelper = new ResetAppsHelper(getActivity());
  }
 @Override
 public void onResume() {
   super.onResume();
   updateView();
   updateOptionsMenu();
   if (mApplications != null) {
     mApplications.resume(mSortOrder);
     mApplications.updateLoading();
   }
 }
 @Override
 public void onStop() {
   super.onStop();
   mResetAppsHelper.stop();
 }