Język

JobInfo.Builder.SetEstimatedNetworkBytes(Int64, Int64) Method

Definition

Set the estimated size of network traffic that will be performed by this job, in bytes.

[Android.Runtime.Register("setEstimatedNetworkBytes", "(JJ)Landroid/app/job/JobInfo$Builder;", "", ApiSince=28)]
public Android.App.Job.JobInfo.Builder? SetEstimatedNetworkBytes(long downloadBytes, long uploadBytes);
[<Android.Runtime.Register("setEstimatedNetworkBytes", "(JJ)Landroid/app/job/JobInfo$Builder;", "", ApiSince=28)>]
member this.SetEstimatedNetworkBytes : int64 * int64 -> Android.App.Job.JobInfo.Builder

Parameters

downloadBytes
Int64

The estimated size of network traffic that will be downloaded by this job, in bytes. Use a non-negative value, or NetworkBytesUnknown if unknown.

uploadBytes
Int64

The estimated size of network traffic that will be uploaded by this job, in bytes. Use a non-negative value, or NetworkBytesUnknown if unknown.

Returns

This builder instance.

Attributes

Remarks

Set the estimated size of network traffic that will be performed by this job, in bytes.

Apps are encouraged to provide values that are as accurate as possible, but when the exact size isn't available, an order-of-magnitude estimate can be provided instead. Here are some specific examples:

A job that is backing up a photo knows the exact size of that photo, so it should provide that size as the estimate.

A job that refreshes top news stories wouldn't know an exact size, but if the size is expected to be consistently around 100KB, it can provide that order-of-magnitude value as the estimate.

A job that synchronizes email could end up using an extreme range of data, from under 1KB when nothing has changed, to dozens of MB when there are new emails with attachments. Jobs that cannot provide reasonable estimates should use the sentinel value JobInfo.NETWORK_BYTES_UNKNOWN.

Note that the system may choose to delay jobs with large network usage estimates when the device has a poor network connection, in order to save battery and possible network costs. Starting from Android version Build.VERSION_CODES.S, JobScheduler may attempt to run large jobs when the device is charging and on an unmetered network, even if the network is slow. This gives large jobs an opportunity to make forward progress, even if they risk timing out.

The values provided here only reflect the traffic that will be performed by the base job; if you're using JobWorkItem then you also need to define the network traffic used by each work item when constructing them.

Prior to Android version Build.VERSION_CODES.TIRAMISU, JobScheduler used the estimated transfer numbers in a similar fashion to setMinimumNetworkChunkBytes(long) (to estimate if the work would complete within the time available to job). In other words, JobScheduler treated the transfer as all-or-nothing. Starting from Android version Build.VERSION_CODES.TIRAMISU, JobScheduler will only use the estimated transfer numbers in this manner if minimum chunk sizes have not been provided via setMinimumNetworkChunkBytes(long).

Android reference for android.app.job.JobInfo.Builder.setEstimatedNetworkBytes.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to