Language

JobInfo.Builder.SetRequiredNetwork(NetworkRequest) Method

Definition

Set detailed description of the kind of network your job requires.

[Android.Runtime.Register("setRequiredNetwork", "(Landroid/net/NetworkRequest;)Landroid/app/job/JobInfo$Builder;", "", ApiSince=28)]
public Android.App.Job.JobInfo.Builder? SetRequiredNetwork(Android.Net.NetworkRequest? networkRequest);
[<Android.Runtime.Register("setRequiredNetwork", "(Landroid/net/NetworkRequest;)Landroid/app/job/JobInfo$Builder;", "", ApiSince=28)>]
member this.SetRequiredNetwork : Android.Net.NetworkRequest -> Android.App.Job.JobInfo.Builder

Parameters

networkRequest
NetworkRequest

The detailed description of the kind of network this job requires, or null if no specific kind of network is required. Defining a NetworkSpecifier is only supported for jobs that aren't persisted.

Returns

This builder instance.

Attributes

Remarks

Set detailed description of the kind of network your job requires.

If your job doesn't need a network connection, you don't need to call this method, as the default is null.

A non-null request adds a network constraint; null clears it. The scheduler normally waits for a matching network, but an expired SetOverrideDeadline(Int64) can allow the job to run without one. This method replaces any requirement previously set by SetRequiredNetworkType(NetworkType).

When the job runs, use the network in Network; the default network may not meet the constraint. The property can be null if no network is available. On Android 14 and later, apps targeting Android 14 or later must hold the ACCESS_NETWORK_STATE permission to schedule a job that requires a network.

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

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