當前位置: 首頁>>代碼示例>>Java>>正文


Java DownloadManager.STATUS_FAILED屬性代碼示例

本文整理匯總了Java中android.app.DownloadManager.STATUS_FAILED屬性的典型用法代碼示例。如果您正苦於以下問題:Java DownloadManager.STATUS_FAILED屬性的具體用法?Java DownloadManager.STATUS_FAILED怎麽用?Java DownloadManager.STATUS_FAILED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.app.DownloadManager的用法示例。


在下文中一共展示了DownloadManager.STATUS_FAILED屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onClickUpdate

/**
 * 點擊下載
 */
public void onClickUpdate() {
    if (mDownloadId != 0) {//downloadID不為默認值,表示存在下載任務
        int status = DownloadUtils.queryDownloadStatus(mContext, mDownloadId);
        Log.e("TAG", status + "");
        switch (status) {
            case DownloadManager.STATUS_RUNNING://下載中
                DownloadToast.showShort(mContext, "正在下載,請稍後");
                break;
            case DownloadManager.STATUS_FAILED://下載失敗
                startDownApk();//重新開始下載
                break;
            case DownloadManager.STATUS_SUCCESSFUL://下載成功
                installApk();
                break;
            default:
                break;
        }
    } else {//無下載任務,開始下載
        startDownApk();
    }
}
 
開發者ID:jianesrq0724,項目名稱:UpdateLibrary,代碼行數:24,代碼來源:UpdateDialog.java

示例2: onClickUpdate

/**
 * 點擊下載
 */
public void onClickUpdate() {
    if (mDownloadId != 0) {//downloadID不為默認值,表示存在下載任務
        int status = DownloadUtils.queryDownloadStatus(this, mDownloadId);
        Log.e("TAG", status + "");
        switch (status) {
            case DownloadManager.STATUS_RUNNING://下載中
                DownloadToast.showShort(this, "正在下載,請稍後");
                break;
            case DownloadManager.STATUS_FAILED://下載失敗
                startDownApk();//重新開始下載
                break;
            case DownloadManager.STATUS_SUCCESSFUL://下載成功
                installApk();
                break;
            default:
                break;
        }
    } else {//無下載任務,開始下載
        startDownApk();
    }
}
 
開發者ID:jianesrq0724,項目名稱:UpdateLibrary,代碼行數:24,代碼來源:UpdateActivity.java

示例3: onReceive

@Override
public void onReceive(Context context, Intent intent) {

    DownloadManager.Query query = new DownloadManager.Query();
    query.setFilterById(id, 0);
    Cursor cursor = downloadManager.query(query);

    if(cursor.moveToFirst()) {
        int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
        int reason = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_REASON));

        if(status == DownloadManager.STATUS_SUCCESSFUL) {

            // Si la descarga es correcta abrimos el archivo para instalarlo
            String uriString = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)).replace("file://", "");
            OpenNewVersion(context, uriString);
        }
        else if(status == DownloadManager.STATUS_FAILED) {
            Toast.makeText(context,context.getString(R.string.appupdater_download_filed) + reason,Toast.LENGTH_LONG).show();
        }
    }
}
 
開發者ID:morogoku,項目名稱:MTweaks-KernelAdiutorMOD,代碼行數:22,代碼來源:UtilsLibrary.java

示例4: getStatusTextResId

@StringRes
public int getStatusTextResId() {
    int statusText = 0;
    switch (status) {
        case DownloadManager.STATUS_FAILED:
            statusText = (R.string.STATUS_FAILED);
            break;
        case DownloadManager.STATUS_PAUSED:
            statusText = (R.string.STATUS_PAUSED);

            break;
        case DownloadManager.STATUS_PENDING:
            statusText = (R.string.STATUS_PENDING);
            break;
        case DownloadManager.STATUS_RUNNING:
            statusText = (R.string.STATUS_RUNNING);
            break;
        case DownloadManager.STATUS_SUCCESSFUL:
            statusText = (R.string.STATUS_SUCCESSFUL);
            break;
    }
    return statusText;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:23,代碼來源:DownloadInfo.java

示例5: getHentetStatus

public HentetStatus getHentetStatus(Udsendelse udsendelse) {
  if (!virker()) return null;
  tjekDataOprettet();

  HentetStatus hs = data.hentetStatusFraSlug.get(udsendelse.slug);
  if (hs != null && (hs.status==DownloadManager.STATUS_SUCCESSFUL || hs.status == DownloadManager.STATUS_FAILED)) {
    hs.statustekst = lavStatustekst(hs);
    return hs;
  }

  Long downloadId = data.downloadIdFraSlug.get(udsendelse.slug);
  if (downloadId == null) return null;
  DownloadManager.Query query = new DownloadManager.Query();
  query.setFilterById(downloadId);
  Cursor c = downloadService.query(query);
  if (c==null) return null; // fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/4066198043
  if (!c.moveToFirst()) {
    c.close();
    return null;
  }

  if (hs == null) {
    hs = new HentetStatus();
    data.hentetStatusFraSlug.put(udsendelse.slug, hs);
  }
  hs.status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
  hs.iAlt = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)) / 1000000;
  hs.hentet = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)) / 1000000;
  hs.startUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
  hs.statustekst = lavStatustekst(hs);
  if (hs.status==DownloadManager.STATUS_FAILED || hs.status==DownloadManager.STATUS_PAUSED) {
    int grund = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
    Log.d(udsendelse.slug+ " hs.grund til fejl "+ grund);
    if (grund==DownloadManager.ERROR_INSUFFICIENT_SPACE) hs.statustekst += " - Ikke nok plads";
  }
  c.close();
  //if (!App.PRODUKTION) hs.statustekst+="\n"+hs.startUri+"\n"+hs.destinationFil; // til fejlfinding
  return hs;
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:39,代碼來源:HentedeUdsendelser.java

示例6: checkDownloadStatus

private void checkDownloadStatus() {
    String url = rctParams.hasKey("url") ? rctParams.getString("url") : null;
    String description = rctParams.hasKey("description") ? rctParams.getString("description") : "downloading";
    DownloadManager.Query query = new DownloadManager.Query();
    query.setFilterById(mTaskId);//篩選下載任務,傳入任務ID,可變參數
    Cursor c = downloadManager.query(query);
    if (c.moveToFirst()) {
        int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
        String downloadPath = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME));
        switch (status) {
            case DownloadManager.STATUS_PAUSED:
            case DownloadManager.STATUS_PENDING:
            case DownloadManager.STATUS_RUNNING:
                WritableMap map = Arguments.createMap();
                map.putInt("status", status);
                map.putString("description", description);
                map.putString("url", url);
                sendEvent(mApplicationContext,EVENT_NAME,map);
                break;
            case DownloadManager.STATUS_SUCCESSFUL:
                // String downloadPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + File.separator + description;
                sendMessage(status, downloadPath, url);
                break;
            case DownloadManager.STATUS_FAILED:
                sendMessage(status, description, url);
                break;
        }
    }
}
 
開發者ID:liuhong1happy,項目名稱:react-native-download-manager,代碼行數:29,代碼來源:DownloadFileManager.java

示例7: doInBackground

@Override
public Pair<Integer, Boolean> doInBackground(Void...voids) {
    DownloadManager manager =
            (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
    Cursor c = manager.query(new DownloadManager.Query().setFilterById(
            mDownloadItem.getSystemDownloadId()));
    int statusIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
    int reasonIndex = c.getColumnIndex(DownloadManager.COLUMN_REASON);
    int titleIndex = c.getColumnIndex(DownloadManager.COLUMN_TITLE);
    int status = DownloadManager.STATUS_FAILED;
    Boolean canResolve = false;
    if (c.moveToNext()) {
        status = c.getInt(statusIndex);
        String title = c.getString(titleIndex);
        if (mDownloadInfo == null) {
            // Chrome has been killed, reconstruct a DownloadInfo.
            mDownloadInfo = new DownloadInfo.Builder()
                    .setFileName(title)
                    .setDescription(c.getString(
                            c.getColumnIndex(DownloadManager.COLUMN_DESCRIPTION)))
                    .setMimeType(c.getString(
                            c.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE)))
                    .setContentLength(Long.parseLong(c.getString(
                            c.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))))
                    .build();
        }
        if (status == DownloadManager.STATUS_SUCCESSFUL) {
            mDownloadInfo = DownloadInfo.Builder.fromDownloadInfo(mDownloadInfo)
                    .setFileName(title)
                    .build();
            mDownloadItem.setDownloadInfo(mDownloadInfo);
            canResolve = canResolveDownloadItem(mContext, mDownloadItem, false);
        } else if (status == DownloadManager.STATUS_FAILED) {
            mFailureReason = c.getInt(reasonIndex);
            manager.remove(mDownloadItem.getSystemDownloadId());
        }
    }
    c.close();
    return Pair.create(status, canResolve);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:40,代碼來源:DownloadManagerService.java

示例8: statusMessage

private String statusMessage(Cursor c) {
    String msg;

    switch (c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS))) {
        case DownloadManager.STATUS_FAILED:
            msg = "DownloadInfo failed";
            break;

        case DownloadManager.STATUS_PAUSED:
            msg = "DownloadInfo paused";
            break;

        case DownloadManager.STATUS_PENDING:
            msg = "DownloadInfo pending";
            break;

        case DownloadManager.STATUS_RUNNING:
            msg = "DownloadInfo in progress";
            break;

        case DownloadManager.STATUS_SUCCESSFUL:
            msg = "DownloadInfo complete";
            break;

        default:
            msg = "DownloadInfo is nowhere in sight";
            break;
    }

    return (msg);
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:31,代碼來源:SplashActivity.java

示例9: getCompletedDownloadInfo

/**
 * Retrieve information about a specific download from DownloadManager.
 */
private static CompletedDownloadInfo getCompletedDownloadInfo(
        final DownloadManagerWrapper manager, final long downloadId) {
    final Query query = new Query().setFilterById(downloadId);
    final Cursor cursor = manager.query(query);

    if (null == cursor) {
        return new CompletedDownloadInfo(null, downloadId, DownloadManager.STATUS_FAILED);
    }
    try {
        final String uri;
        final int status;
        if (cursor.moveToNext()) {
            final int columnStatus = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
            final int columnError = cursor.getColumnIndex(DownloadManager.COLUMN_REASON);
            final int columnUri = cursor.getColumnIndex(DownloadManager.COLUMN_URI);
            final int error = cursor.getInt(columnError);
            status = cursor.getInt(columnStatus);
            final String uriWithAnchor = cursor.getString(columnUri);
            int anchorIndex = uriWithAnchor.indexOf('#');
            if (anchorIndex != -1) {
                uri = uriWithAnchor.substring(0, anchorIndex);
            } else {
                uri = uriWithAnchor;
            }
            if (DownloadManager.STATUS_SUCCESSFUL != status) {
                Log.e(TAG, "Permanent failure of download " + downloadId
                        + " with error code: " + error);
            }
        } else {
            uri = null;
            status = DownloadManager.STATUS_FAILED;
        }
        return new CompletedDownloadInfo(uri, downloadId, status);
    } finally {
        cursor.close();
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:40,代碼來源:UpdateHandler.java

示例10: checkStatus

private void checkStatus() {
    //cause SQLiteException at 樂視 LE X820 Android 6.0.1,level 23
    try{
        DownloadManager.Query query = new DownloadManager.Query();
        query.setFilterById(downloadId);
        Cursor c = downloadManager.query(query);
        if (c.moveToFirst()) {
            int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
            switch (status) {
                case DownloadManager.STATUS_PAUSED:
                    break;
                case DownloadManager.STATUS_PENDING:
                    break;
                case DownloadManager.STATUS_RUNNING:
                    break;
                case DownloadManager.STATUS_SUCCESSFUL:
                    String tip = mContext.getString(R.string.download_complete)
                            .concat("\n").concat(getFilePath());
                    Toasty.success(mContext, tip).show();
                    unregister();
                    break;
                case DownloadManager.STATUS_FAILED:
                    Toasty.error(mContext, mContext.getString(R.string.download_failed)).show();
                    unregister();
                    break;
            }
        }
        c.close();
    }catch (SQLiteException e){
        Logger.d(e);
        unregister();
    }

}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:34,代碼來源:Downloader.java

示例11: includeDownloadFromCursor

@SuppressLint("InlinedApi")
private void includeDownloadFromCursor(MatrixCursor result, Cursor cursor) {
       final long id = cursor.getLong(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_ID));
       final String docId = String.valueOf(id);

       final String displayName = cursor.getString(
               cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TITLE));
       String summary = cursor.getString(
               cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_DESCRIPTION));
       String mimeType = cursor.getString(
               cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIA_TYPE));
       if (mimeType == null) {
           // Provide fake MIME type so it's openable
           mimeType = "vnd.android.document/file";
       }
       Long size = cursor.getLong(
               cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES));
       if (size == -1) {
           size = null;
       }

       final int status = cursor.getInt(
               cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS));
       switch (status) {
           case DownloadManager.STATUS_SUCCESSFUL:
               break;
           case DownloadManager.STATUS_PAUSED:
               summary = getContext().getString(R.string.download_queued);
               break;
           case DownloadManager.STATUS_PENDING:
               summary = getContext().getString(R.string.download_queued);
               break;
           case DownloadManager.STATUS_RUNNING:
               final long progress = cursor.getLong(cursor.getColumnIndexOrThrow(
                       DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR));
               if (size != null) {
                   final long percent = progress * 100 / size;
                   summary = getContext().getString(R.string.download_running_percent, percent);
               } else {
                   summary = getContext().getString(R.string.download_running);
               }
               break;
           case DownloadManager.STATUS_FAILED:
           default:
               summary = getContext().getString(R.string.download_error);
               break;
       }

       int flags = Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE;
       if (mimeType != null && mimeType.startsWith("image/")) {
           flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
       }

       final long lastModified = cursor.getLong(
               cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP));

       final RowBuilder row = result.newRow();
       row.add(Document.COLUMN_DOCUMENT_ID, docId);
       row.add(Document.COLUMN_DISPLAY_NAME, displayName);
       row.add(Document.COLUMN_SUMMARY, summary);
       row.add(Document.COLUMN_SIZE, size);
       row.add(Document.COLUMN_MIME_TYPE, mimeType);
       row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
       row.add(Document.COLUMN_FLAGS, flags);
   }
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:65,代碼來源:DownloadStorageProvider.java

示例12: downloadVideoFile

@ReactMethod public void downloadVideoFile(String uri, final Promise downloadPromise) {
  this.downloadUri = uri;
  this.downloadPromise = downloadPromise;
  dm = (DownloadManager) getReactApplicationContext().
      getSystemService(Context.DOWNLOAD_SERVICE);

  getReactApplicationContext().
      registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

  if (Prefs.isUriAlreadyDownloaded(uri)) {
    WritableMap localUri = new WritableNativeMap();
    localUri.putString("uri", Prefs.getLocalUri());
    downloadPromise.resolve(localUri);
  } else if(Prefs.getDownloadId() != -1) {
    // if file downloaded in background, save it to internal storage
    Cursor c = dm.query(new DownloadManager.Query().setFilterById(Prefs.getDownloadId()));
    if (c.moveToFirst()) {
      int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
      switch (status) {
        case DownloadManager.STATUS_PAUSED:
          break;
        case DownloadManager.STATUS_PENDING:
          break;
        case DownloadManager.STATUS_RUNNING:
          break;
        case DownloadManager.STATUS_SUCCESSFUL:
          Prefs.setDownloading(false);
          enqueue = Prefs.getDownloadId();
          saveToLocalStorage();
          break;
        case DownloadManager.STATUS_FAILED:
          break;
      }
    }

  } else {
    if (!Prefs.isDownloading()) {
      if (!Prefs.isUriAlreadyDownloaded(uri)) {
        Prefs.setDownloading(true);
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(uri));
        request.setVisibleInDownloadsUi(false);
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);

        request.setDestinationInExternalFilesDir(getReactApplicationContext(),
            DIRECTORY_DOWNLOADS, URLUtil.guessFileName(uri, null, null) + ".mp4");

        enqueue = dm.enqueue(request);
        Prefs.saveDownloadId(enqueue);
      }
    }
  }

  progressRunnable = new Runnable() {
    @Override
    public void run() {
      checkProgress();
    }
  };

  future = this.executor.scheduleWithFixedDelay(progressRunnable, 1L, 1, TimeUnit.SECONDS);


}
 
開發者ID:humaniq,項目名稱:react-native-android-library-humaniq-api,代碼行數:63,代碼來源:DownloadModule.java

示例13: doInBackground

@Override
public DownloadQueryResult doInBackground(Void... voids) {
    DownloadManager manager =
            (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
    Cursor c = manager.query(
            new DownloadManager.Query().setFilterById(mDownloadItem.getSystemDownloadId()));
    if (c == null) {
        return new DownloadQueryResult(mDownloadItem,
                DownloadManagerService.DOWNLOAD_STATUS_CANCELLED, 0, 0, false, 0);
    }
    long bytesDownloaded = 0;
    boolean canResolve = false;
    int downloadStatus = DownloadManagerService.DOWNLOAD_STATUS_IN_PROGRESS;
    int failureReason = 0;
    long lastModifiedTime = 0;
    if (c.moveToNext()) {
        int statusIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
        int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
        if (status == DownloadManager.STATUS_SUCCESSFUL) {
            downloadStatus = DownloadManagerService.DOWNLOAD_STATUS_COMPLETE;
            if (mShowNotifications) {
                canResolve = DownloadManagerService.isOMADownloadDescription(
                        mDownloadItem.getDownloadInfo())
                        || DownloadManagerService.canResolveDownloadItem(
                                mContext, mDownloadItem, false);
            }
        } else if (status == DownloadManager.STATUS_FAILED) {
            downloadStatus = DownloadManagerService.DOWNLOAD_STATUS_FAILED;
            failureReason = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
        }
        lastModifiedTime =
                c.getLong(c.getColumnIndex(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP));
        bytesDownloaded =
                c.getLong(c.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR));
    } else {
        downloadStatus = DownloadManagerService.DOWNLOAD_STATUS_CANCELLED;
    }
    c.close();
    long totalTime = Math.max(0, lastModifiedTime - mDownloadItem.getStartTime());
    return new DownloadQueryResult(mDownloadItem, downloadStatus, totalTime,
            bytesDownloaded, canResolve, failureReason);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:42,代碼來源:DownloadManagerDelegate.java

示例14: getReasonDebugString

public static String getReasonDebugString(int status, int reason) {
    String reasonText = "unKnown_status";
    switch (status) {
        case DownloadManager.STATUS_FAILED:
            switch (reason) {
                case DownloadManager.ERROR_CANNOT_RESUME:
                    reasonText = "ERROR_CANNOT_RESUME";
                    break;
                case DownloadManager.ERROR_DEVICE_NOT_FOUND:
                    reasonText = "(ERROR_DEVICE_NOT_FOUND)";
                    break;
                case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
                    reasonText = "(ERROR_FILE_ALREADY_EXISTS)";
                    break;
                case DownloadManager.ERROR_FILE_ERROR:
                    reasonText = "(ERROR_FILE_ERROR)";
                    break;
                case DownloadManager.ERROR_HTTP_DATA_ERROR:
                    reasonText = "(ERROR_HTTP_DATA_ERROR)";
                    break;
                case DownloadManager.ERROR_INSUFFICIENT_SPACE:
                    reasonText = "(ERROR_INSUFFICIENT_SPACE)";
                    break;
                case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
                    reasonText = "(ERROR_TOO_MANY_REDIRECTS)";
                    break;
                case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
                    reasonText = "(ERROR_UNHANDLED_HTTP_CODE)";
                    break;
                case DownloadManager.ERROR_UNKNOWN:
                    reasonText = "(ERROR_UNKNOWN)";
                    break;
            }
            break;
        case DownloadManager.STATUS_PAUSED: {
            switch (reason) {
                case DownloadManager.PAUSED_QUEUED_FOR_WIFI:
                    reasonText = "PAUSED_QUEUED_FOR_WIFI";
                    break;
                case DownloadManager.PAUSED_UNKNOWN:
                    reasonText = "PAUSED_UNKNOWN";
                    break;
                case DownloadManager.PAUSED_WAITING_FOR_NETWORK:
                    reasonText = "PAUSED_WAITING_FOR_NETWORK";
                    break;
                case DownloadManager.PAUSED_WAITING_TO_RETRY:
                    reasonText = "PAUSED_WAITING_TO_RETRY";
                    break;
            }
            break;
        }
    }
    return reasonText;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:54,代碼來源:DownloadInfo.java

示例15: onReceive

/**
 * {@inheritDoc}
 */
@Override
public void onReceive(Context context, Intent intent) {
    try {
        //Check if the broadcast message is for our enqueued download
        long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
        if (referenceId == this.currentDicoDownloadReference) {
            DownloadManager downloadManager = (DownloadManager) context.getSystemService(context.DOWNLOAD_SERVICE);
            //Retrieve the status of the downloaded file
            DownloadManager.Query downloadQuery = new DownloadManager.Query();
            //Set the query filter to our previously Enqueued download
            downloadQuery.setFilterById(this.currentDicoDownloadReference);
            //Query the download manager about downloads that have been requested.
            Cursor cursor = downloadManager.query(downloadQuery);
            if (cursor.moveToFirst()) {
                //Get the download status
                int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
                int status = cursor.getInt(columnIndex);
                if (status == DownloadManager.STATUS_SUCCESSFUL) {
                    //Get the downloaded file path
                    columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI);
                    String filePath = cursor.getString(columnIndex);
                    //Send Intent to the Post download file processor Service
                    Intent downloadFileProcessIntent = new Intent(context, PostDownloadService.class);
                    downloadFileProcessIntent.putExtra(PostDownloadService.EXTRA_PARAM_DL_FILE_PATH, filePath);
                    downloadFileProcessIntent.putExtra(PostDownloadService.EXTRA_PARAM_TARGET_FILE_PATH, this.targetFilePath);
                    downloadFileProcessIntent.setAction(PostDownloadService.ACTION_DL_FILE_PROCESS);
                    context.startService(downloadFileProcessIntent);
                    NotificationUtil.sendNotification(context, "Dictionary download OK, pass to post processing...");
                } else if (status == DownloadManager.STATUS_FAILED) {
                    //Get fail reason
                    String reasonText = "";
                    int columnReason = cursor.getColumnIndex(DownloadManager.COLUMN_REASON);
                    int reason = cursor.getInt(columnReason);
                    switch (reason) {
                        case DownloadManager.ERROR_CANNOT_RESUME:
                            reasonText = "ERROR_CANNOT_RESUME";
                            break;
                        case DownloadManager.ERROR_DEVICE_NOT_FOUND:
                            reasonText = "ERROR_DEVICE_NOT_FOUND";
                            break;
                        case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
                            reasonText = "ERROR_FILE_ALREADY_EXISTS";
                            break;
                        case DownloadManager.ERROR_FILE_ERROR:
                            reasonText = "ERROR_FILE_ERROR";
                            break;
                        case DownloadManager.ERROR_HTTP_DATA_ERROR:
                            reasonText = "ERROR_HTTP_DATA_ERROR";
                            break;
                        case DownloadManager.ERROR_INSUFFICIENT_SPACE:
                            reasonText = "ERROR_INSUFFICIENT_SPACE";
                            break;
                        case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
                            reasonText = "ERROR_TOO_MANY_REDIRECTS";
                            break;
                        case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
                            reasonText = "ERROR_UNHANDLED_HTTP_CODE";
                            break;
                        case DownloadManager.ERROR_UNKNOWN:
                            reasonText = "ERROR_UNKNOWN";
                            break;
                    }
                    NotificationUtil.sendNotification(context, "Dictionary download fail for reason '" + reasonText + "' !");
                }
            }
        }

    } catch (Exception e) {
        String msg = "Error during the download file processing: " + e.getMessage();
        Log.e(MainActivity.LOG_TAG, msg, e);
        NotificationUtil.sendNotification(context, msg);
    }
}
 
開發者ID:righettod,項目名稱:access-brute-forcer,代碼行數:76,代碼來源:DownloadReceiver.java


注:本文中的android.app.DownloadManager.STATUS_FAILED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。