Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.annotation.TargetApi;

import android.app.DownloadManager;
import android.content.Context;

import android.os.Build;

public class Main {
    /**
     * Attempts to notify the system's download manager, if available, that a file has been
     * downloaded.
     * 
     * @see {@link DownloadManager#addCompletedDownload(String, String, boolean, String, String, long, boolean)}
     */
    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
    public static long addToDownloadManager(Context context, String title, String description,
            boolean isMediaScannerScannable, String mimeType, String path, long length, boolean showNotification) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
            if (downloadManager != null) {
                return downloadManager.addCompletedDownload(title, description, isMediaScannerScannable, mimeType,
                        path, length, showNotification);
            }
        }
        return 0L;
    }
}