Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/view/SurfaceControlViewHost#nestedclasses) \| [Ctors](https://developer.android.com/reference/android/view/SurfaceControlViewHost#pubctors) \| [Methods](https://developer.android.com/reference/android/view/SurfaceControlViewHost#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/view/SurfaceControlViewHost#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/SurfaceControlViewHost#inhmethods)

# SurfaceControlViewHost

*** ** * ** ***


`
public


class
SurfaceControlViewHost
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.SurfaceControlViewHost |

<br />

*** ** * ** ***

Utility class for adding a View hierarchy to a `https://developer.android.com/reference/android/view/SurfaceControl`. The View hierarchy
will render in to a root SurfaceControl, and receive input based on the SurfaceControl's
placement on-screen. The primary usage of this class is to embed a View hierarchy from
one process in to another. After the SurfaceControlViewHost has been set up in the embedded
content provider, we can send the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage`
to the host process. The host process can then attach the hierarchy to a SurfaceView within
its own by calling
`https://developer.android.com/reference/android/view/SurfaceView#setChildSurfacePackage(android.view.SurfaceControlViewHost.SurfacePackage)`.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` Specifies the layout parameters for a `https://developer.android.com/reference/android/view/View` hosted by a `https://developer.android.com/reference/android/view/SurfaceControlViewHost`. |
| ` class` | `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` Package encapsulating a Surface hierarchy which contains interactive view elements. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#SurfaceControlViewHost(android.content.Context,%20android.view.Display,%20android.os.IBinder)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/view/Display display, https://developer.android.com/reference/android/os/IBinder hostToken) ` Construct a new SurfaceControlViewHost. |
| ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#SurfaceControlViewHost(android.content.Context,%20android.view.Display,%20android.window.InputTransferToken)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/view/Display display, https://developer.android.com/reference/android/window/InputTransferToken hostInputTransferToken) ` Construct a new SurfaceControlViewHost. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#getLayoutParams()() ` Returns the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` of the root view. |
| ` https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#getSurfacePackage()() ` Return a SurfacePackage for the root SurfaceControl of the embedded hierarchy. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#getView()() ` |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#relayout(android.view.SurfaceControlViewHost.LayoutParams)(https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams attrs) ` Modifies the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` of the root view. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#relayout(int,%20int)(int width, int height) ` Modify the size of the root view. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#release()() ` Trigger the tear down of the embedded view hierarchy and release the SurfaceControl. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#setView(android.view.View,%20int,%20int)(https://developer.android.com/reference/android/view/View view, int width, int height) ` Set the root view of the SurfaceControlViewHost. |
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#setView(android.view.View,%20android.view.SurfaceControlViewHost.LayoutParams)(https://developer.android.com/reference/android/view/View view, https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams attrs) ` Sets the root view of the `https://developer.android.com/reference/android/view/SurfaceControlViewHost`. |
| ` boolean` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#transferTouchGestureToHost()() ` *This method was deprecated in API level 35. Use `https://developer.android.com/reference/android/view/WindowManager#transferTouchGesture(android.window.InputTransferToken,%20android.window.InputTransferToken)` instead.* |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/SurfaceControlViewHost#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public constructors

### SurfaceControlViewHost

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

```
public SurfaceControlViewHost (Context context, 
                Display display, 
                IBinder hostToken)
```

Construct a new SurfaceControlViewHost. The root Surface will be
allocated internally and is accessible via getSurfacePackage().

The `hostToken` parameter, primarily used for ANR reporting,
must be obtained from whomever will be hosting the embedded hierarchy.
It's accessible from `https://developer.android.com/reference/android/view/SurfaceView#getHostToken()`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The Context object for your activity or application. This value cannot be `null`. <br /> |
| `display` | `Display`: The Display the hierarchy will be placed on. This value cannot be `null`. <br /> |
| `hostToken` | `IBinder`: The host token, as discussed above. This value may be `null`. <br /> |

### SurfaceControlViewHost

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

```
public SurfaceControlViewHost (Context context, 
                Display display, 
                InputTransferToken hostInputTransferToken)
```

Construct a new SurfaceControlViewHost. The root Surface will be
allocated internally and is accessible via getSurfacePackage().


The hostInputTransferToken parameter allows the host and embedded to be associated with
each other to allow transferring touch gesture and focus. This is also used for ANR
reporting. It's accessible from `https://developer.android.com/reference/android/view/AttachedSurfaceControl#getInputTransferToken()`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The Context object for your activity or application. This value cannot be `null`. <br /> |
| `display` | `Display`: The Display the hierarchy will be placed on. This value cannot be `null`. <br /> |
| `hostInputTransferToken` | `InputTransferToken`: The host input transfer token, as discussed above. This value may be `null`. <br /> |

## Public methods

### getLayoutParams

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

```
public SurfaceControlViewHost.LayoutParams getLayoutParams ()
```

Returns the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` of the root view.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` | This value cannot be `null`. <br /> |

### getSurfacePackage

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

```
public SurfaceControlViewHost.SurfacePackage getSurfacePackage ()
```

Return a SurfacePackage for the root SurfaceControl of the embedded hierarchy.
Rather than be directly reparented using `https://developer.android.com/reference/android/view/SurfaceControl.Transaction` this
SurfacePackage should be passed to `https://developer.android.com/reference/android/view/SurfaceView#setChildSurfacePackage(android.view.SurfaceControlViewHost.SurfacePackage)`
which will not only reparent the Surface, but ensure the accessibility hierarchies
are linked.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` | This value may be `null`. <br /> |

### getView

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

```
public View getView ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The view passed to setView, or null if none has been passed. <br /> |

### relayout

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

```
public void relayout (SurfaceControlViewHost.LayoutParams attrs)
```

Modifies the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` of the root view.

<br />

| Parameters ||
|---|---|
| `attrs` | `SurfaceControlViewHost.LayoutParams`: This value cannot be `null`. <br /> |

### relayout

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

```
public void relayout (int width, 
                int height)
```

Modify the size of the root view.

<br />

| Parameters ||
|---|---|
| `width` | `int`: Width in pixels <br /> |
| `height` | `int`: Height in pixels <br /> |

### release

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

```
public void release ()
```

Trigger the tear down of the embedded view hierarchy and release the SurfaceControl.
This will result in onDispatchedFromWindow being dispatched to the embedded view hierarchy
and render the object unusable.

<br />

### setView

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

```
public void setView (View view, 
                int width, 
                int height)
```

Set the root view of the SurfaceControlViewHost. This view will render in to
the SurfaceControl, and receive input based on the SurfaceControls positioning on
screen. It will be laid as if it were in a window of the passed in width and height.

<br />

| Parameters ||
|---|---|
| `view` | `View`: The View to add. This value cannot be `null`. <br /> |
| `width` | `int`: The width to layout the View within, in pixels. <br /> |
| `height` | `int`: The height to layout the View within, in pixels. <br /> |

### setView

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

```
public void setView (View view, 
                SurfaceControlViewHost.LayoutParams attrs)
```

Sets the root view of the `https://developer.android.com/reference/android/view/SurfaceControlViewHost`. This view will render in to the
SurfaceControl, and receive input based on the SurfaceControl's positioning on screen. It
will be laid out as if it were in a window of the passed in width and height.

<br />

| Parameters ||
|---|---|
| `view` | `View`: The `https://developer.android.com/reference/android/view/View` to add. This value cannot be `null`. <br /> |
| `attrs` | `SurfaceControlViewHost.LayoutParams`: The `https://developer.android.com/reference/android/view/SurfaceControlViewHost.LayoutParams` parameters for the `https://developer.android.com/reference/android/view/View`. This value cannot be `null`. <br /> |

### transferTouchGestureToHost

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

```
public boolean transferTouchGestureToHost ()
```


**This method was deprecated
in API level 35.**   

Use `https://developer.android.com/reference/android/view/WindowManager#transferTouchGesture(android.window.InputTransferToken,%20android.window.InputTransferToken)` instead.

Transfer the currently in progress touch gesture to the parent (if any) of this
SurfaceControlViewHost. This requires that the SurfaceControlViewHost was created with an
associated host `https://developer.android.com/reference/android/window/InputTransferToken`.

<br />

| Returns ||
|---|---|
| `boolean` | Whether the touch stream was transferred. <br /> |

## Protected methods

### finalize

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

```
protected void finalize ()
```

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the `finalize` method to dispose of
system resources or to perform other cleanup.


The general contract of `finalize` is that it is invoked
if and when the Java virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The `finalize` method may take any action, including
making this object available again to other threads; the usual purpose
of `finalize`, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.


The `finalize` method of class `Object` performs no
special action; it simply returns normally. Subclasses of
`Object` may override this definition.


The Java programming language does not guarantee which thread will
invoke the `finalize` method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.


After the `finalize` method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.


The `finalize` method is never invoked more than once by a Java
virtual machine for any given object.


Any exception thrown by the `finalize` method causes
the finalization of this object to be halted, but is otherwise
ignored.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Throwable` |   |