MediaTransferReceiver
public
final
class
MediaTransferReceiver
extends BroadcastReceiver
java.lang.Object | ||
↳ | android.content.BroadcastReceiver | |
↳ | androidx.mediarouter.media.MediaTransferReceiver |
A BroadcastReceiver
class for enabling Media transfer feature.
Media transfer is a feature that media routing can be controlled via system UI. By using this, media app users can re-route the media without opening the app activity again. Also, the media can be transferred from one device to another device seamlessly, depending on the devices. This feature is supported from Android 11.
To enable the media transfer feature, media apps should declare this receiver in the app's manifest. For example:
<application>
<receiver android:name="androidx.mediarouter.media.MediaTransferReceiver" />
</application>
Media apps that enable this feature should implement the MediaRouter.Callback
properly.
Specifically:
- Apps should be able to get events even when the app is in background. This means
that the callback should not be removed in
Activity.onStop()
. (SeeMediaRouter.addCallback(MediaRouteSelector, MediaRouter.Callback, int)
for how to add callback. - Apps should handle the case where the media routing is changed from the outside of the
app. The callback's
onRouteSelected
method should be able to handle the cases. - In order to enable transferring media from remote to local (e.g. from TV to phone),
media apps should
enable 'transfer to local' feature
. Otherwise, the local devices won't be shown as a transfer target while playing on a remote device.
Summary
Public constructors | |
---|---|
MediaTransferReceiver()
|
Public methods | |
---|---|
void
|
onReceive(Context context, Intent intent)
|
Inherited methods | |
---|---|
Public constructors
MediaTransferReceiver
public MediaTransferReceiver ()