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

MediaRouteDiscoveryRequest

public final class MediaRouteDiscoveryRequest extends Object
Describes the kinds of routes that the media router would like to discover and whether to perform active scanning.

This object is immutable once created.

Fields Summary
private static final String
KEY_SELECTOR
private static final String
KEY_ACTIVE_SCAN
private final android.os.Bundle
mBundle
private MediaRouteSelector
mSelector
Constructors Summary
public MediaRouteDiscoveryRequest(MediaRouteSelector selector, boolean activeScan)
Creates a media route discovery request.

param
selector The route selector that specifies the kinds of routes to discover.
param
activeScan True if active scanning should be performed.


                                     
         
        if (selector == null) {
            throw new IllegalArgumentException("selector must not be null");
        }

        mBundle = new Bundle();
        mSelector = selector;
        mBundle.putBundle(KEY_SELECTOR, selector.asBundle());
        mBundle.putBoolean(KEY_ACTIVE_SCAN, activeScan);
    
private MediaRouteDiscoveryRequest(android.os.Bundle bundle)

        mBundle = bundle;
    
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;
    
private voidensureSelector()

        if (mSelector == null) {
            mSelector = MediaRouteSelector.fromBundle(mBundle.getBundle(KEY_SELECTOR));
            if (mSelector == null) {
                mSelector = MediaRouteSelector.EMPTY;
            }
        }
    
public booleanequals(java.lang.Object o)

        if (o instanceof MediaRouteDiscoveryRequest) {
            MediaRouteDiscoveryRequest other = (MediaRouteDiscoveryRequest)o;
            return getSelector().equals(other.getSelector())
                    && isActiveScan() == other.isActiveScan();
        }
        return false;
    
public static android.support.v7.media.MediaRouteDiscoveryRequestfromBundle(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 MediaRouteDiscoveryRequest(bundle) : null;
    
public MediaRouteSelectorgetSelector()
Gets the route selector that specifies the kinds of routes to discover.

        ensureSelector();
        return mSelector;
    
public inthashCode()

        return getSelector().hashCode() ^ (isActiveScan() ? 1 : 0);
    
public booleanisActiveScan()
Returns true if active scanning should be performed.

see
MediaRouter#CALLBACK_FLAG_PERFORM_ACTIVE_SCAN

        return mBundle.getBoolean(KEY_ACTIVE_SCAN);
    
public booleanisValid()
Returns true if the discovery request has all of the required fields.

        ensureSelector();
        return mSelector.isValid();
    
public java.lang.StringtoString()

        StringBuilder result = new StringBuilder();
        result.append("DiscoveryRequest{ selector=").append(getSelector());
        result.append(", activeScan=").append(isActiveScan());
        result.append(", isValid=").append(isValid());
        result.append(" }");
        return result.toString();