Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/media/MediaRouter2.TransferCallback#pubctors) \| [Methods](https://developer.android.com/reference/android/media/MediaRouter2.TransferCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/MediaRouter2.TransferCallback#inhmethods)

# MediaRouter2.TransferCallback

*** ** * ** ***

` public static abstract class MediaRouter2.TransferCallback `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.MediaRouter2.TransferCallback |

<br />

*** ** * ** ***

Callback for receiving events on media transfer.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/media/MediaRouter2.TransferCallback#TransferCallback()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/media/MediaRouter2.TransferCallback#onStop(android.media.MediaRouter2.RoutingController)(https://developer.android.com/reference/android/media/MediaRouter2.RoutingController controller) ` Called when a media routing stops. |
| ` void` | ` https://developer.android.com/reference/android/media/MediaRouter2.TransferCallback#onTransfer(android.media.MediaRouter2.RoutingController,%20android.media.MediaRouter2.RoutingController)(https://developer.android.com/reference/android/media/MediaRouter2.RoutingController oldController, https://developer.android.com/reference/android/media/MediaRouter2.RoutingController newController) ` Called when a media is transferred between two different routing controllers. |
| ` void` | ` https://developer.android.com/reference/android/media/MediaRouter2.TransferCallback#onTransferFailure(android.media.MediaRoute2Info)(https://developer.android.com/reference/android/media/MediaRoute2Info requestedRoute) ` Called when `https://developer.android.com/reference/android/media/MediaRouter2#transferTo(android.media.MediaRoute2Info)` failed. |

### 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

### TransferCallback

```
public TransferCallback ()
```

<br />

<br />

## Public methods

### onStop

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

```
public void onStop (MediaRouter2.RoutingController controller)
```

Called when a media routing stops. It can be stopped by a user or a provider. App should not continue playing media locally when this method is called. The `controller` is released before this method is called.

<br />

| Parameters ||
|---|---|
| `controller` | `MediaRouter2.RoutingController`: the controller that controlled the stopped media routing. This value cannot be `null`. <br /> |

### onTransfer

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

```
public void onTransfer (MediaRouter2.RoutingController oldController, 
                MediaRouter2.RoutingController newController)
```

Called when a media is transferred between two different routing controllers. This can happen by calling `https://developer.android.com/reference/android/media/MediaRouter2#transferTo(android.media.MediaRoute2Info)`.

Override this to start playback with `newController`. You may want to get the status of the media that is being played with `oldController` and resume it continuously with `newController`. After this is called, any callbacks with `oldController` will not be invoked unless `oldController` is the `https://developer.android.com/reference/android/media/MediaRouter2#getSystemController()`. You need to `https://developer.android.com/reference/android/media/MediaRouter2.RoutingController#release()` `oldController` before playing the media with `newController`.

<br />

| Parameters ||
|---|---|
| `oldController` | `MediaRouter2.RoutingController`: the previous controller that controlled routing. This value cannot be `null`. <br /> |
| `newController` | `MediaRouter2.RoutingController`: the new controller to control routing. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/MediaRouter2#transferTo(android.media.MediaRoute2Info)`

### onTransferFailure

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

```
public void onTransferFailure (MediaRoute2Info requestedRoute)
```

Called when `https://developer.android.com/reference/android/media/MediaRouter2#transferTo(android.media.MediaRoute2Info)` failed.

<br />

| Parameters ||
|---|---|
| `requestedRoute` | `MediaRoute2Info`: the route info which was used for the transfer. This value cannot be `null`. <br /> |