Java Code Examples for android.app.DownloadManager#ERROR_UNKNOWN

The following examples show how to use android.app.DownloadManager#ERROR_UNKNOWN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadManagerService.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a download fails.
 *
 * @param fileName Name of the download file.
 * @param reason Reason of failure reported by android DownloadManager
 */
protected void onDownloadFailed(String fileName, int reason) {
    String reasonString = mContext.getString(
            R.string.download_failed_reason_unknown_error, fileName);
    switch (reason) {
        case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
            reasonString = mContext.getString(
                    R.string.download_failed_reason_file_already_exists, fileName);
            break;
        case DownloadManager.ERROR_FILE_ERROR:
            reasonString = mContext.getString(
                    R.string.download_failed_reason_file_system_error, fileName);
            break;
        case DownloadManager.ERROR_INSUFFICIENT_SPACE:
            reasonString = mContext.getString(
                    R.string.download_failed_reason_insufficient_space, fileName);
            break;
        case DownloadManager.ERROR_CANNOT_RESUME:
        case DownloadManager.ERROR_HTTP_DATA_ERROR:
            reasonString = mContext.getString(
                    R.string.download_failed_reason_network_failures, fileName);
            break;
        case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
        case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
            reasonString = mContext.getString(
                    R.string.download_failed_reason_server_issues, fileName);
            break;
        case DownloadManager.ERROR_DEVICE_NOT_FOUND:
            reasonString = mContext.getString(
                    R.string.download_failed_reason_storage_not_found, fileName);
            break;
        case DownloadManager.ERROR_UNKNOWN:
        default:
            break;
    }
    mDownloadSnackbarController.onDownloadFailed(
            reasonString, reason == DownloadManager.ERROR_FILE_ALREADY_EXISTS);
}
 
Example 2
Source File: DownloadManagerService.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 3
Source File: DownloadManagerService.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source File: DownloadInfo.java    From IslamicLibraryAndroid with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
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;
}
 
Example 5
Source File: DownloadInfo.java    From IslamicLibraryAndroid with GNU General Public License v3.0 4 votes vote down vote up
@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;
}
 
Example 6
Source File: GeoPackageDownloadManager.java    From mage-android with Apache License 2.0 4 votes vote down vote up
private String getDownloadFailureStatus(Cursor cursor) {
    String status = null;

    if (cursor.moveToFirst()) {
        int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_REASON);
        if(columnIndex != -1) {
            int reason = cursor.getInt(columnIndex);

            switch (reason) {
                case DownloadManager.ERROR_CANNOT_RESUME:
                    status = "Cannot Resume";
                    break;
                case DownloadManager.ERROR_DEVICE_NOT_FOUND:
                    status = "Device Not Found";
                    break;
                case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
                    status = "File Already Exists";
                    break;
                case DownloadManager.ERROR_FILE_ERROR:
                    status = "File Error";
                    break;
                case DownloadManager.ERROR_HTTP_DATA_ERROR:
                    status = "HTTP Data Error";
                    break;
                case DownloadManager.ERROR_INSUFFICIENT_SPACE:
                    status = "Insufficient Space";
                    break;
                case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
                    status = "Too Many Redirects";
                    break;
                case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
                    status = "Unhandled HTTP Code";
                    break;
                case DownloadManager.ERROR_UNKNOWN:
                default:
                    status = "Unknown Error";
                    break;
            }
        }
    }

    return status;
}
 
Example 7
Source File: BackgroundDownload.java    From cordova-plugin-background-download with Apache License 2.0 4 votes vote down vote up
private static String getUserFriendlyReason(int reason) {
    String failedReason = "";
    switch (reason) {
        case DownloadManager.ERROR_CANNOT_RESUME:
            failedReason = "ERROR_CANNOT_RESUME";
            break;
        case DownloadManager.ERROR_DEVICE_NOT_FOUND:
            failedReason = "ERROR_DEVICE_NOT_FOUND";
            break;
        case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
            failedReason = "ERROR_FILE_ALREADY_EXISTS";
            break;
        case DownloadManager.ERROR_FILE_ERROR:
            failedReason = "ERROR_FILE_ERROR";
            break;
        case DownloadManager.ERROR_HTTP_DATA_ERROR:
            failedReason = "ERROR_HTTP_DATA_ERROR";
            break;
        case DownloadManager.ERROR_INSUFFICIENT_SPACE:
            failedReason = "ERROR_INSUFFICIENT_SPACE";
            break;
        case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
            failedReason = "ERROR_TOO_MANY_REDIRECTS";
            break;
        case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
            failedReason = "ERROR_UNHANDLED_HTTP_CODE";
            break;
        case DownloadManager.ERROR_UNKNOWN:
            failedReason = "ERROR_UNKNOWN";
            break;
        case HttpURLConnection.HTTP_BAD_REQUEST:
            failedReason = "BAD_REQUEST";
            break;
        case HttpURLConnection.HTTP_UNAUTHORIZED:
            failedReason = "UNAUTHORIZED";
            break;
        case HttpURLConnection.HTTP_FORBIDDEN:
            failedReason = "FORBIDDEN";
            break;
        case HttpURLConnection.HTTP_NOT_FOUND:
            failedReason = "NOT_FOUND";
            break;
        case HttpURLConnection.HTTP_INTERNAL_ERROR:
            failedReason = "INTERNAL_SERVER_ERROR";
            break;
        case ERROR_CANCELED:
            failedReason = "CANCELED";
            break;
    }

    return failedReason;
}