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


Java DownloadManager.ERROR_FILE_ALREADY_EXISTS屬性代碼示例

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


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

示例1: onDownloadItemCanceled

/**
 * Called when a download is canceled before download target is determined.
 *
 * @param fileName Name of the download file.
 * @param reason Reason of failure reported by android DownloadManager.
 */
@CalledByNative
private static void onDownloadItemCanceled(String fileName, boolean isExternalStorageMissing) {
    DownloadManagerService service = getDownloadManagerService(
            ContextUtils.getApplicationContext());
    int reason = isExternalStorageMissing ? DownloadManager.ERROR_DEVICE_NOT_FOUND
            : DownloadManager.ERROR_FILE_ALREADY_EXISTS;
    service.onDownloadFailed(fileName, reason);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:DownloadManagerService.java

示例2: getDownloadFailureMessage

/**
 * Get the message to display when a download fails.
 *
 * @param fileName Name of the download file.
 * @param reason Reason of failure reported by android DownloadManager.
 */
private String getDownloadFailureMessage(String fileName, int reason) {
    switch (reason) {
        case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
            return mContext.getString(
                    R.string.download_failed_reason_file_already_exists, fileName);
        case DownloadManager.ERROR_FILE_ERROR:
            return mContext.getString(
                    R.string.download_failed_reason_file_system_error, fileName);
        case DownloadManager.ERROR_INSUFFICIENT_SPACE:
            return mContext.getString(
                    R.string.download_failed_reason_insufficient_space, fileName);
        case DownloadManager.ERROR_CANNOT_RESUME:
        case DownloadManager.ERROR_HTTP_DATA_ERROR:
            return mContext.getString(
                    R.string.download_failed_reason_network_failures, fileName);
        case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
        case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
            return mContext.getString(
                    R.string.download_failed_reason_server_issues, fileName);
        case DownloadManager.ERROR_DEVICE_NOT_FOUND:
            return mContext.getString(
                    R.string.download_failed_reason_storage_not_found, fileName);
        case DownloadManager.ERROR_UNKNOWN:
        default:
            return mContext.getString(
                    R.string.download_failed_reason_unknown_error, fileName);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:34,代碼來源:DownloadManagerService.java

示例3: 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

示例4: getReasonTextResId

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

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