@Override
    protected Void doInBackground(Void... params) {
      try {
        final LocalRepoManager lrm = LocalRepoManager.get(SwapActivity.this);
        publishProgress(getString(R.string.deleting_repo));
        lrm.deleteRepo();
        for (String app : selectedApps) {
          publishProgress(String.format(getString(R.string.adding_apks_format), app));
          lrm.addApp(SwapActivity.this, app);
        }
        lrm.writeIndexPage(sharingUri.toString());
        publishProgress(getString(R.string.writing_index_jar));
        lrm.writeIndexJar();
        publishProgress(getString(R.string.linking_apks));
        lrm.copyApksToRepo();
        publishProgress(getString(R.string.copying_icons));
        // run the icon copy without progress, its not a blocker
        new AsyncTask<Void, Void, Void>() {

          @Override
          protected Void doInBackground(Void... params) {
            lrm.copyIconsToRepo();
            return null;
          }
        }.execute();
      } catch (Exception e) {
        Log.e(TAG, "An error occured while setting up the local repo", e);
      }
      return null;
    }
  @Override
  public void onResume() {
    super.onResume();
    resetNetworkInfo();
    setRepoSwitchChecked(FDroidApp.isLocalRepoServiceRunnig());

    LocalBroadcastManager.getInstance(this)
        .registerReceiver(onWifiChange, new IntentFilter(WifiStateChangeService.BROADCAST));
    LocalBroadcastManager.getInstance(this)
        .registerReceiver(onLocalRepoChange, new IntentFilter(LocalRepoService.STATE));
    // if no local repo exists, create one with only FDroid in it
    if (!LocalRepoManager.get(this).xmlIndex.exists())
      new UpdateAsyncTask(
              this,
              new String[] {
                getPackageName(),
              })
          .execute();

    // start repo by default
    FDroidApp.startLocalRepoService(LocalRepoActivity.this);
    // reset the timer if viewing this Activity again
    if (stopTimer != null) stopTimer.cancel();
    // automatically turn off after 15 minutes
    stopTimer = new Timer();
    stopTimer.schedule(
        new TimerTask() {

          @Override
          public void run() {
            FDroidApp.stopLocalRepoService(LocalRepoActivity.this);
          }
        },
        900000); // 15 minutes
  }