FileDocCategorySizeDatePackage
MediaRouteDescriptor.javaAPI DocAndroid 5.1 API15417Thu Mar 12 22:22:56 GMT 2015android.support.v7.media

MediaRouteDescriptor

public final class MediaRouteDescriptor extends Object
Describes the properties of a route.

Each route is uniquely identified by an opaque id string. This token may take any form as long as it is unique within the media route provider.

This object is immutable once created using a {@link Builder} instance.

Fields Summary
private static final String
KEY_ID
private static final String
KEY_NAME
private static final String
KEY_DESCRIPTION
private static final String
KEY_ENABLED
private static final String
KEY_CONNECTING
private static final String
KEY_CONTROL_FILTERS
private static final String
KEY_PLAYBACK_TYPE
private static final String
KEY_PLAYBACK_STREAM
private static final String
KEY_VOLUME
private static final String
KEY_VOLUME_MAX
private static final String
KEY_VOLUME_HANDLING
private static final String
KEY_PRESENTATION_DISPLAY_ID
private static final String
KEY_EXTRAS
private static final String
KEY_CAN_DISCONNECT
private static final String
KEY_SETTINGS_INTENT
private final android.os.Bundle
mBundle
private List
mControlFilters
Constructors Summary
private MediaRouteDescriptor(android.os.Bundle bundle, List controlFilters)


         
        mBundle = bundle;
        mControlFilters = controlFilters;
    
Methods Summary
public android.os.BundleasBundle()
Converts this object to a bundle for serialization.

return
The contents of the object represented as a bundle.

        return mBundle;
    
public booleancanDisconnectAndKeepPlaying()
Gets whether the route can be disconnected without stopping playback. To specify that the route should disconnect without stopping use {@link MediaRouter#unselect(int)} with {@link MediaRouter#UNSELECT_REASON_DISCONNECTED}.

        return mBundle.getBoolean(KEY_CAN_DISCONNECT, false);
    
private voidensureControlFilters()

        if (mControlFilters == null) {
            mControlFilters = mBundle.<IntentFilter>getParcelableArrayList(KEY_CONTROL_FILTERS);
            if (mControlFilters == null) {
                mControlFilters = Collections.<IntentFilter>emptyList();
            }
        }
    
public static android.support.v7.media.MediaRouteDescriptorfromBundle(android.os.Bundle bundle)
Creates an instance from a bundle.

param
bundle The bundle, or null if none.
return
The new instance, or null if the bundle was null.

        return bundle != null ? new MediaRouteDescriptor(bundle, null) : null;
    
public java.util.ListgetControlFilters()
Gets the route's {@link MediaControlIntent media control intent} filters.

        ensureControlFilters();
        return mControlFilters;
    
public java.lang.StringgetDescription()
Gets the user-visible description of the route.

The route description describes the kind of destination represented by the route. It may be a user-supplied string, a model number or brand of device.

        return mBundle.getString(KEY_DESCRIPTION);
    
public android.os.BundlegetExtras()
Gets a bundle of extras for this route descriptor. The extras will be ignored by the media router but they may be used by applications.

        return mBundle.getBundle(KEY_EXTRAS);
    
public java.lang.StringgetId()
Gets the unique id of the route.

The route id associated with a route descriptor functions as a stable identifier for the route and must be unique among all routes offered by the provider.

        return mBundle.getString(KEY_ID);
    
public java.lang.StringgetName()
Gets the user-visible name of the route.

The route name identifies the destination represented by the route. It may be a user-supplied name, an alias, or device serial number.

        return mBundle.getString(KEY_NAME);
    
public intgetPlaybackStream()
Gets the route's playback stream.

        return mBundle.getInt(KEY_PLAYBACK_STREAM, -1);
    
public intgetPlaybackType()
Gets the route's playback type.

        return mBundle.getInt(KEY_PLAYBACK_TYPE, MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE);
    
public intgetPresentationDisplayId()
Gets the route's presentation display id, or -1 if none.

        return mBundle.getInt(KEY_PRESENTATION_DISPLAY_ID, -1);
    
public android.content.IntentSendergetSettingsActivity()
Gets an {@link IntentSender} for starting a settings activity for this route. The activity may have specific route settings or general settings for the connected device or route provider.

return
An {@link IntentSender} to start a settings activity.

        return mBundle.getParcelable(KEY_SETTINGS_INTENT);
    
public intgetVolume()
Gets the route's current volume, or 0 if unknown.

        return mBundle.getInt(KEY_VOLUME);
    
public intgetVolumeHandling()
Gets the route's volume handling.

        return mBundle.getInt(KEY_VOLUME_HANDLING,
                MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED);
    
public intgetVolumeMax()
Gets the route's maximum volume, or 0 if unknown.

        return mBundle.getInt(KEY_VOLUME_MAX);
    
public booleanisConnecting()
Gets whether the route is connecting.

        return mBundle.getBoolean(KEY_CONNECTING, false);
    
public booleanisEnabled()
Gets whether the route is enabled.

        return mBundle.getBoolean(KEY_ENABLED, true);
    
public booleanisValid()
Returns true if the route descriptor has all of the required fields.

        ensureControlFilters();
        if (TextUtils.isEmpty(getId())
                || TextUtils.isEmpty(getName())
                || mControlFilters.contains(null)) {
            return false;
        }
        return true;
    
public java.lang.StringtoString()

        StringBuilder result = new StringBuilder();
        result.append("MediaRouteDescriptor{ ");
        result.append("id=").append(getId());
        result.append(", name=").append(getName());
        result.append(", description=").append(getDescription());
        result.append(", isEnabled=").append(isEnabled());
        result.append(", isConnecting=").append(isConnecting());
        result.append(", controlFilters=").append(Arrays.toString(getControlFilters().toArray()));
        result.append(", playbackType=").append(getPlaybackType());
        result.append(", playbackStream=").append(getPlaybackStream());
        result.append(", volume=").append(getVolume());
        result.append(", volumeMax=").append(getVolumeMax());
        result.append(", volumeHandling=").append(getVolumeHandling());
        result.append(", presentationDisplayId=").append(getPresentationDisplayId());
        result.append(", extras=").append(getExtras());
        result.append(", isValid=").append(isValid());
        result.append(" }");
        return result.toString();