public void askBeforeInstall() {
    // hack to get theme applied (which is not automatically applied due to activity's
    // Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(theme);
    alertBuilder.setTitle(R.string.system_install_question);
    String message = InstallExtension.create(getApplicationContext()).getWarningString();
    alertBuilder.setMessage(Html.fromHtml(message));
    alertBuilder.setPositiveButton(
        R.string.system_install_button_install,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            checkRootTask.execute();
          }
        });
    alertBuilder.setNegativeButton(
        R.string.cancel,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
            InstallExtensionDialogActivity.this.finish();
          }
        });
    alertBuilder.create().show();
  }
        @Override
        protected void onPreExecute() {
          super.onPreExecute();

          // hack to get theme applied (which is not automatically applied due to activity's
          // Theme.NoDisplay
          ContextThemeWrapper theme =
              new ContextThemeWrapper(
                  InstallExtensionDialogActivity.this, FDroidApp.getCurThemeResId());

          mProgressDialog = new ProgressDialog(theme);
          mProgressDialog.setMessage(
              InstallExtension.create(getApplicationContext()).getInstallingString());
          mProgressDialog.setIndeterminate(true);
          mProgressDialog.setCancelable(false);
          mProgressDialog.show();
        }
  private void uninstall() {
    // hack to get theme applied (which is not automatically applied due to activity's
    // Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    final boolean isInstalled = PrivilegedInstaller.isExtensionInstalled(this);

    if (isInstalled) {
      String message = InstallExtension.create(getApplicationContext()).getWarningString();

      AlertDialog.Builder builder =
          new AlertDialog.Builder(theme)
              .setTitle(R.string.system_uninstall)
              .setMessage(Html.fromHtml(message))
              .setPositiveButton(
                  R.string.system_uninstall_button,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                      checkRootTask.execute();
                    }
                  })
              .setNegativeButton(
                  R.string.cancel,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
                      InstallExtensionDialogActivity.this.finish();
                    }
                  });
      builder.create().show();
    } else {
      throw new RuntimeException("Uninstall invoked, but extension is not installed!");
    }
  }
 @Override
 protected Void doInBackground(Void... voids) {
   InstallExtension.create(getApplicationContext()).runUninstall();
   return null;
 }