# PackageInstaller.InstallConstraints.Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/content/pm/PackageInstaller.InstallConstraints.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                                   ||
| ↳ | [android.content.pm.PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) |

Builder class for constructing[InstallConstraints](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints).

## Summary

|                                                               Public constructors                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                   ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [PackageInstaller.InstallConstraints](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints)                  | [build](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#build())`()` Builds a new[InstallConstraints](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints)instance. |
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | [setAppNotForegroundRequired](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#setAppNotForegroundRequired())`()` This constraint requires the app in question is not in the foreground.                               |
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | [setAppNotInteractingRequired](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#setAppNotInteractingRequired())`()` This constraint requires the app in question is not interacting with the user.                     |
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | [setAppNotTopVisibleRequired](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#setAppNotTopVisibleRequired())`()` This constraint requires the app in question is not top-visible to the user.                         |
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | [setDeviceIdleRequired](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#setDeviceIdleRequired())`()` This constraint requires the device is idle.                                                                     |
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | [setNotInCallRequired](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#setNotInCallRequired())`()` This constraint requires there is no ongoing call in the device.                                                   |

## Public constructors

### Builder

```
Builder()
```

## Public methods

### build

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): PackageInstaller.InstallConstraints
```

Builds a new[InstallConstraints](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints)instance.

|                                                                                  Return                                                                                   ||
|----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [PackageInstaller.InstallConstraints](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints) | This value cannot be`null`. |

### setAppNotForegroundRequired

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setAppNotForegroundRequired(): PackageInstaller.InstallConstraints.Builder
```

This constraint requires the app in question is not in the foreground.

|                                                                                           Return                                                                                           ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | This value cannot be`null`. |

### setAppNotInteractingRequired

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setAppNotInteractingRequired(): PackageInstaller.InstallConstraints.Builder
```

This constraint requires the app in question is not interacting with the user. User interaction includes:

- playing or recording audio/video
- sending or receiving network data
- being visible to the user

<br />

|                                                                                           Return                                                                                           ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | This value cannot be`null`. |

### setAppNotTopVisibleRequired

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setAppNotTopVisibleRequired(): PackageInstaller.InstallConstraints.Builder
```

This constraint requires the app in question is not top-visible to the user. A top-visible app is showing UI at the top of the screen that the user is interacting with. Note this constraint is a subset of[setAppNotForegroundRequired()](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#setAppNotForegroundRequired())because a top-visible app is also a foreground app. This is also a subset of[setAppNotInteractingRequired()](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#setAppNotInteractingRequired())because a top-visible app is interacting with the user.

|                                                                                           Return                                                                                           ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | This value cannot be`null`. |

**See Also**

- [android.app.ActivityManager.RunningAppProcessInfo#IMPORTANCE_FOREGROUND](https://developer.android.com/reference/kotlin/android/app/ActivityManager.RunningAppProcessInfo.html#IMPORTANCE_FOREGROUND:kotlin.Int)  

### setDeviceIdleRequired

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setDeviceIdleRequired(): PackageInstaller.InstallConstraints.Builder
```

This constraint requires the device is idle.

|                                                                                           Return                                                                                           ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | This value cannot be`null`. |

### setNotInCallRequired

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setNotInCallRequired(): PackageInstaller.InstallConstraints.Builder
```

This constraint requires there is no ongoing call in the device.

|                                                                                           Return                                                                                           ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [PackageInstaller.InstallConstraints.Builder](https://developer.android.com/reference/kotlin/android/content/pm/PackageInstaller.InstallConstraints.Builder#) | This value cannot be`null`. |