当前位置: 首页>>代码示例>>Java>>正文


Java DownloadManager.ERROR_UNKNOWN属性代码示例

本文整理汇总了Java中android.app.DownloadManager.ERROR_UNKNOWN属性的典型用法代码示例。如果您正苦于以下问题:Java DownloadManager.ERROR_UNKNOWN属性的具体用法?Java DownloadManager.ERROR_UNKNOWN怎么用?Java DownloadManager.ERROR_UNKNOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.app.DownloadManager的用法示例。


在下文中一共展示了DownloadManager.ERROR_UNKNOWN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

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

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

示例4: 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_UNKNOWN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。