JobInfo.Builder.SetImportantWhileForeground(Boolean) 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.
Setting this to true indicates that this job is important while the scheduling app is in the foreground or on the temporary allowlist for background restrictions.
[Android.Runtime.Register("setImportantWhileForeground", "(Z)Landroid/app/job/JobInfo$Builder;", "", ApiSince=28)]
public Android.App.Job.JobInfo.Builder? SetImportantWhileForeground(bool importantWhileForeground);
[<Android.Runtime.Register("setImportantWhileForeground", "(Z)Landroid/app/job/JobInfo$Builder;", "", ApiSince=28)>]
member this.SetImportantWhileForeground : bool -> Android.App.Job.JobInfo.Builder
Parameters
- importantWhileForeground
- Boolean
whether to relax doze restrictions for this job when the app is in the foreground. False by default.
Returns
This builder instance, including on Android 16 and later where the flag has no effect.
- Attributes
Remarks
This method was deprecated in API level 31. Use setExpedited(boolean) instead.
Setting this to true indicates that this job is important while the scheduling app is in the foreground or on the temporary allowlist for background restrictions. This means that the system will relax doze restrictions on this job during this time. Apps should use this flag only for short jobs that are essential for the app to function properly in the foreground. Note that once the scheduling app is no longer allowlisted from background restrictions and in the background, or the job failed due to unsatisfied constraints, this job should be expected to behave like other jobs without this flag.
Jobs marked as important-while-foreground are given JobInfo.PRIORITY_HIGH by default.
Note: Beginning with Build.VERSION_CODES.BAKLAVA, this flag will be ignored and no longer function effectively, regardless of the calling app's target SDK version. JobInfo.isImportantWhileForeground() will always return false. Apps should use setExpedited(boolean) with true to indicate that this job is important and needs to run as soon as possible.
Android reference for android.app.job.JobInfo.Builder.setImportantWhileForeground.
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.