/**
   * If the download successfully spins up a new thread to start downloading, then we return true,
   * otherwise false. This is useful, e.g. when we use a cached version, and so don't want to bother
   * with progress dialogs et al.
   */
  public boolean download() {

    // Can we use the cached version?
    if (verifyOrDeleteCachedVersion()) {
      sendCompleteMessage();
      return false;
    }

    String remoteAddress = getRemoteAddress();
    Log.d(TAG, "Downloading apk from " + remoteAddress);

    try {
      Downloader downloader = DownloaderFactory.create(remoteAddress, localFile);
      dlWrapper = new AsyncDownloadWrapper(downloader, this);
      dlWrapper.download();
      return true;

    } catch (MalformedURLException e) {
      onErrorDownloading(e.getLocalizedMessage());
    } catch (IOException e) {
      onErrorDownloading(e.getLocalizedMessage());
    }

    return false;
  }
 /**
  * Attempts to cancel the download (if in progress) and also removes the progress listener (to
  * prevent
  */
 public void cancel() {
   if (dlWrapper != null) {
     dlWrapper.attemptCancel();
   }
 }