JobInfo.Builder.SetRequiredNetwork(NetworkRequest) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
Calling this method defines network as a strict requirement for your job. If the network requested is not available your job will never run. See setOverrideDeadline(long) to change this behavior. Calling this method will override any requirements previously defined by setRequiredNetworkType(int); you typically only want to call one of these methods.
When your job executes in JobService.onStartJob(JobParameters), be sure to use the specific network returned by JobParameters.getNetwork(), otherwise you'll use the default network which may not meet this constraint. Starting in Android version Build.VERSION_CODES.UPSIDE_DOWN_CAKE, an app must hold the Manifest.permission.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.