# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Constants | Ctors | Methods | Inherited Methods

# DownloadManager.Request

`public static class DownloadManager.Request`
`extends Object` ``

java.lang.Object
↳ | android.app.DownloadManager.Request

This class contains all the information necessary to request a new download. The URI is the only required parameter. Note that the default download destination is a shared volume where the system might delete your file if it needs to reclaim space for system use. If this is a problem, use a location on external storage (see `setDestinationUri(android.net.Uri)`.

## Summary

### Constants
`int` | `NETWORK_MOBILE` Bit flag for `setAllowedNetworkTypes(int)` corresponding to `ConnectivityManager#TYPE_MOBILE`.
`int` | `NETWORK_WIFI` Bit flag for `setAllowedNetworkTypes(int)` corresponding to `ConnectivityManager#TYPE_WIFI`.
`int` | `VISIBILITY_HIDDEN` This download doesn't show in the UI or in the notifications.
`int` | `VISIBILITY_VISIBLE` This download is visible but only shows in the notifications while it's in progress.
`int` | `VISIBILITY_VISIBLE_NOTIFY_COMPLETED` This download is visible and shows in the notifications while in progress and after completion.
`int` | `VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION` This download shows in the notifications after completion ONLY.

### Public constructors
`Request(Uri uri)`

### Public methods
`DownloadManager.Request` | `addRequestHeader(String header, String value)` Add an HTTP header to be included with the download request.
`void` | `allowScanningByMediaScanner()` This method is deprecated. Starting in Q, this value is ignored. Files downloaded to directories owned by applications (e.g. `Context#getExternalFilesDir(String)`) will not be scanned by MediaScanner and the rest will be scanned.
`DownloadManager.Request` | `setAllowedNetworkTypes(int flags)` Restrict the types of networks over which this download may proceed.
`DownloadManager.Request` | `setAllowedOverMetered(boolean allow)` Set whether this download may proceed over a metered network connection.
`DownloadManager.Request` | `setAllowedOverRoaming(boolean allowed)` Set whether this download may proceed over a roaming connection.
`DownloadManager.Request` | `setDescription(CharSequence description)` Set a description of this download, to be displayed in notifications (if enabled)
`DownloadManager.Request` | `setDestinationInExternalFilesDir(Context context, String dirType, String subPath)` Set the local destination for the downloaded file to a path within the application's external files directory (as returned by `Context#getExternalFilesDir(String)`.
`DownloadManager.Request` | `setDestinationInExternalPublicDir(String dirType, String subPath)` Set the local destination for the downloaded file to a path within the public external storage directory (as returned by `Environment#getExternalStoragePublicDirectory(String)`).
`DownloadManager.Request` | `setDestinationUri(Uri uri)` Set the local destination for the downloaded file.
`DownloadManager.Request` | `setMimeType(String mimeType)` Set the MIME content type of this download.
`DownloadManager.Request` | `setNotificationVisibility(int visibility)` Control whether a system notification is posted by the download manager while this download is running or when it is completed.
`DownloadManager.Request` | `setRequiresCharging(boolean requiresCharging)` Specify that to run this download, the device needs to be plugged in.
`DownloadManager.Request` | `setRequiresDeviceIdle(boolean requiresDeviceIdle)` Specify that to run, the download needs the device to be in idle mode.
`DownloadManager.Request` | `setShowRunningNotification(boolean show)` This method is deprecated. use `setNotificationVisibility(int)`
`DownloadManager.Request` | `setTitle(CharSequence title)` Set the title of this download, to be displayed in notifications (if enabled).
`DownloadManager.Request` | `setVisibleInDownloadsUi(boolean isVisible)` This method is deprecated. Starting in Q, this value is ignored. Only files downloaded to public Downloads directory (as returned by `Environment#getExternalStoragePublicDirectory(String)` with `Environment#DIRECTORY_DOWNLOADS`) will be visible in system's Downloads UI and the rest will not be visible. (e.g. `Context#getExternalFilesDir(String)`) will not be visible.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Constants

### NETWORK_MOBILE

    public static final int NETWORK_MOBILE

Bit flag for `setAllowedNetworkTypes(int)` corresponding to `ConnectivityManager#TYPE_MOBILE`.

Constant Value: 1 (0x00000001)

### NETWORK_WIFI

    public static final int NETWORK_WIFI

Bit flag for `setAllowedNetworkTypes(int)` corresponding to `ConnectivityManager#TYPE_WIFI`.

Constant Value: 2 (0x00000002)

### VISIBILITY_HIDDEN

    public static final int VISIBILITY_HIDDEN

This download doesn't show in the UI or in the notifications.

Constant Value: 2 (0x00000002)

### VISIBILITY_VISIBLE

    public static final int VISIBILITY_VISIBLE

This download is visible but only shows in the notifications while it's in progress.

Constant Value: 0 (0x00000000)

### VISIBILITY_VISIBLE_NOTIFY_COMPLETED

    public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED

This download is visible and shows in the notifications while in progress and after completion.

Constant Value: 1 (0x00000001)

### VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION

    public static final int VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION

This download shows in the notifications after completion ONLY. It is usuable only with `DownloadManager#addCompletedDownload(String, String, boolean, String, String, long, boolean)`.

Constant Value: 3 (0x00000003)

## Public constructors

### Request

    public Request (Uri uri)

Parameters
`uri` | `Uri`: the HTTP or HTTPS URI to download.

## Public methods

### addRequestHeader

    public DownloadManager.Request addRequestHeader (String header,
                    String value)

Add an HTTP header to be included with the download request. The header will be added to the end of the list.

Parameters
`header` | `String`: HTTP header name
`value` | `String`: header value

Returns
`DownloadManager.Request` | this object

See also:

- HTTP/1.1 Message Headers

### allowScanningByMediaScanner

    public void allowScanningByMediaScanner ()

This method is deprecated.
Starting in Q, this value is ignored. Files downloaded to directories owned by applications (e.g. `Context#getExternalFilesDir(String)`) will not be scanned by MediaScanner and the rest will be scanned.

If the file to be downloaded is to be scanned by MediaScanner, this method should be called before `DownloadManager#enqueue(Request)` is called.

### setAllowedNetworkTypes

    public DownloadManager.Request setAllowedNetworkTypes (int flags)

Restrict the types of networks over which this download may proceed. By default, all network types are allowed. Consider using `setAllowedOverMetered(boolean)` instead, since it's more flexible.

As of `Build.VERSION_CODES.N`, setting only the `NETWORK_WIFI` flag here is equivalent to calling `setAllowedOverMetered(boolean)` with `false`.

Parameters
`flags` | `int`: any combination of the NETWORK_* bit flags.

Returns
`DownloadManager.Request` | this object

### setAllowedOverMetered

    public DownloadManager.Request setAllowedOverMetered (boolean allow)

Set whether this download may proceed over a metered network connection. By default, metered networks are allowed.

Parameters
`allow` | `boolean`

Returns
`DownloadManager.Request` |

See also:

- `ConnectivityManager.isActiveNetworkMetered()`

### setAllowedOverRoaming

    public DownloadManager.Request setAllowedOverRoaming (boolean allowed)

Set whether this download may proceed over a roaming connection. By default, roaming is allowed.

Parameters
`allowed` | `boolean`: whether to allow a roaming connection to be used

Returns
`DownloadManager.Request` | this object

### setDescription

    public DownloadManager.Request setDescription (CharSequence description)

Set a description of this download, to be displayed in notifications (if enabled)

Parameters
`description` | `CharSequence`

Returns
`DownloadManager.Request` | this object

### setDestinationInExternalFilesDir

    public DownloadManager.Request setDestinationInExternalFilesDir (Context context,
                    String dirType,
                    String subPath)

Set the local destination for the downloaded file to a path within the application's external files directory (as returned by `Context#getExternalFilesDir(String)`.

The downloaded file is not scanned by MediaScanner. But it can be made scannable by calling `allowScanningByMediaScanner()`.

Parameters
`context` | `Context`: the `Context` to use in determining the external files directory
`dirType` | `String`: the directory type to pass to `Context#getExternalFilesDir(String)`
`subPath` | `String`: the path within the external directory, including the destination filename

Returns
`DownloadManager.Request` | this object

Throws
`IllegalStateException` | If the external storage directory cannot be found or created.

### setDestinationInExternalPublicDir

    public DownloadManager.Request setDestinationInExternalPublicDir (String dirType,
                    String subPath)

Set the local destination for the downloaded file to a path within the public external storage directory (as returned by `Environment#getExternalStoragePublicDirectory(String)`).

The downloaded file is not scanned by MediaScanner. But it can be made scannable by calling `allowScanningByMediaScanner()`.

For applications targeting `Build.VERSION_CODES.Q` or above, `WRITE_EXTERNAL_STORAGE` permission is not needed and the `dirType` must be one of the known public directories like `Environment#DIRECTORY_DOWNLOADS`, `Environment#DIRECTORY_PICTURES`, `Environment#DIRECTORY_MOVIES`, etc.

Parameters
`dirType` | `String`: the directory type to pass to `Environment#getExternalStoragePublicDirectory(String)`
`subPath` | `String`: the path within the external directory, including the destination filename

Returns
`DownloadManager.Request` | this object

Throws
`IllegalStateException` | If the external storage directory cannot be found or created.

### setDestinationUri

    public DownloadManager.Request setDestinationUri (Uri uri)

Set the local destination for the downloaded file. Must be a file URI to a path on external storage, and the calling application must have the WRITE_EXTERNAL_STORAGE permission.

The downloaded file is not scanned by MediaScanner. But it can be made scannable by calling `allowScanningByMediaScanner()`.

By default, downloads are saved to a generated filename in the shared download cache and may be deleted by the system at any time to reclaim space.

For applications targeting `Build.VERSION_CODES.Q` or above, `WRITE EXTERNAL_STORAGE` permission is not needed and the `uri` must refer to a path within the directories owned by the application (e.g. `Context#getExternalFilesDir(String)`) or a path within the top-level Downloads directory (as returned by `Environment#getExternalStoragePublicDirectory(String)` with `Environment#DIRECTORY_DOWNLOADS`).

Parameters
`uri` | `Uri`: a file `Uri` indicating the destination for the downloaded file.

Returns
`DownloadManager.Request` | this object

### setMimeType

    public DownloadManager.Request setMimeType (String mimeType)

Set the MIME content type of this download. This will override the content type declared in the server's response.

Parameters
`mimeType` | `String`

Returns
`DownloadManager.Request` | this object

See also:

- HTTP/1.1 Media Types

### setNotificationVisibility

    public DownloadManager.Request setNotificationVisibility (int visibility)

Control whether a system notification is posted by the download manager while this download is running or when it is completed. If enabled, the download manager posts notifications about downloads through the system `NotificationManager`. By default, a notification is shown only when the download is in progress.

It can take the following values: `VISIBILITY_HIDDEN`, `VISIBILITY_VISIBLE`, `VISIBILITY_VISIBLE_NOTIFY_COMPLETED`.

If set to `VISIBILITY_HIDDEN`, this requires the permission android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.

Parameters
`visibility` | `int`: the visibility setting value

Returns
`DownloadManager.Request` | this object

### setRequiresCharging

    public DownloadManager.Request setRequiresCharging (boolean requiresCharging)

Specify that to run this download, the device needs to be plugged in. This defaults to false.

Parameters
`requiresCharging` | `boolean`: Whether or not the device is plugged in.

Returns
`DownloadManager.Request` |

See also:

- `JobInfo.Builder.setRequiresCharging(boolean)`

### setRequiresDeviceIdle

    public DownloadManager.Request setRequiresDeviceIdle (boolean requiresDeviceIdle)

Specify that to run, the download needs the device to be in idle mode. This defaults to false.

Idle mode is a loose definition provided by the system, which means that the device is not in use, and has not been in use for some time.

Parameters
`requiresDeviceIdle` | `boolean`: Whether or not the device need be within an idle maintenance window.

Returns
`DownloadManager.Request` |

See also:

- `JobInfo.Builder.setRequiresDeviceIdle(boolean)`

### setShowRunningNotification

    public DownloadManager.Request setShowRunningNotification (boolean show)

This method is deprecated.
use `setNotificationVisibility(int)`

Control whether a system notification is posted by the download manager while this download is running. If enabled, the download manager posts notifications about downloads through the system `NotificationManager`. By default, a notification is shown. If set to false, this requires the permission android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.

Parameters
`show` | `boolean`: whether the download manager should show a notification for this download.

Returns
`DownloadManager.Request` | this object

### setTitle

    public DownloadManager.Request setTitle (CharSequence title)

Set the title of this download, to be displayed in notifications (if enabled). If no title is given, a default one will be assigned based on the download filename, once the download starts.

Parameters
`title` | `CharSequence`

Returns
`DownloadManager.Request` | this object

### setVisibleInDownloadsUi

    public DownloadManager.Request setVisibleInDownloadsUi (boolean isVisible)

This method is deprecated.
Starting in Q, this value is ignored. Only files downloaded to public Downloads directory (as returned by `Environment#getExternalStoragePublicDirectory(String)` with `Environment#DIRECTORY_DOWNLOADS`) will be visible in system's Downloads UI and the rest will not be visible. (e.g. `Context#getExternalFilesDir(String)`) will not be visible.

Set whether this download should be displayed in the system's Downloads UI. True by default.

Parameters
`isVisible` | `boolean`: whether to display this download in the Downloads UI

Returns
`DownloadManager.Request` | this object

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*