# PrivacySandboxInterface

Artifact:[androidx.privacysandbox.tools:tools](https://developer.android.com/jetpack/androidx/releases/privacysandbox-tools)  
[View Source](https://cs.android.com/search?q=file:androidx/privacysandbox/tools/PrivacySandboxInterface.kt+class:androidx.privacysandbox.tools.PrivacySandboxInterface)  
Added in[1.0.0-alpha14](https://developer.android.com/jetpack/androidx/releases/privacysandbox-tools#1.0.0-alpha14)  
Deprecated in[1.0.0-alpha14](https://developer.android.com/jetpack/androidx/releases/privacysandbox-tools#1.0.0-alpha14)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/privacysandbox/tools/PrivacySandboxInterface "View this page in Java")

<br />

```
@Retention(value = AnnotationRetention.RUNTIME)
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation PrivacySandboxInterface
```

<br />

*** ** * ** ***

| **This annotation is deprecated.**   
| This library is no longer supported.

Annotated interfaces used by the app to communicate with the SDK in the Privacy Sandbox.

Functions in a[PrivacySandboxInterface](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxInterface)annotated interface must obey the following rules:

- Functions with return values must suspend

- Parameter types may be primitives,[PrivacySandboxValue](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxValue),[PrivacySandboxCallback](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxCallback),[PrivacySandboxInterface](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxInterface), or lists of primitives or[PrivacySandboxValue](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxValue). Nullable types are allowed.

- Return types may be primitives,[PrivacySandboxValue](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxValue),[PrivacySandboxInterface](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxInterface), or lists of primitives or[PrivacySandboxValue](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxValue). Nullable types are allowed.

Suspend functions operate as follows:

- The main thread is used by default

- App cancellations are propagated to SDK coroutines

- Cancellation exceptions thrown by SDKs are packaged and rethrown as valid[CancellationException](https://developer.android.com/reference/java/util/concurrent/CancellationException.html)s

Additionally, all exceptions thrown by SDK suspend function implementations are wrapped and rethrown to app developers as`PrivacySandboxException`with a full stack trace. Errors in non-suspend functions will not be rethrown.

[PrivacySandboxInterface](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxInterface)annotated interfaces may not extend any interface except for one of the Privacy Sandbox UI adapters, such as[androidx.privacysandbox.ui.core.SandboxedUiAdapter](https://developer.android.com/reference/kotlin/androidx/privacysandbox/ui/core/SandboxedUiAdapter)or[androidx.privacysandbox.ui.core.SharedUiAdapter](https://developer.android.com/reference/kotlin/androidx/privacysandbox/ui/core/SharedUiAdapter), which can be used to provide SDK content in an app's UI. These interfaces may also have any other functions that are normally allowed.

Usage example:  

```kotlin
@PrivacySandboxInterface
interface MyInterface {
    suspend fun doSomething(request: Request): Response
    suspend fun getMyInterface(input: MyInterface): MyInterface
    suspend fun getNullableInterface(input: MySecondInterface): MySecondInterface?
    fun setListener(listener: MyCallback)
    fun appendValue(x: Int)
}
```

## Summary

|                                                                                                        ### Public constructors                                                                                                         |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ~~[PrivacySandboxInterface](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxInterface#PrivacySandboxInterface())~~`()` **This function is deprecated.**This library is no longer supported. |

## Public constructors

### PrivacySandboxInterface

```
[PrivacySandboxInterface](https://developer.android.com/reference/kotlin/androidx/privacysandbox/tools/PrivacySandboxInterface#PrivacySandboxInterface())()
```
| **This function is deprecated.**   
| This library is no longer supported.