@Override
  public void onCreate() {
    // VMRuntime.getRuntime().setMinimumHeapSize(4 * 1024 * 1024);
    super.onCreate();

    SettingUtils.loadLauncherSettings(this);

    mContext = getApplicationContext();
    mIconCache = new IconCache(this);
    mModel = new LauncherModel(this, mIconCache);

    // Register intent receivers
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    registerReceiver(mModel, filter);
    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    registerReceiver(mModel, filter);

    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    registerReceiver(mModel, filter);

    // Register for changes to the favorites
    ContentResolver resolver = getContentResolver();
    resolver.registerContentObserver(
        LauncherSettings.Favorites.CONTENT_URI, true, mFavoritesObserver);
  }
  /** There's no guarantee that this function is ever called. */
  @Override
  public void onTerminate() {
    super.onTerminate();
    SettingUtils.saveScreenSettings(this);
    unregisterReceiver(mModel);

    ContentResolver resolver = getContentResolver();
    resolver.unregisterContentObserver(mFavoritesObserver);
  }