FileDocCategorySizeDatePackage
NetworkRequest.javaAPI DocAndroid 5.1 API8411Thu Mar 12 22:22:10 GMT 2015android.net

NetworkRequest

public class NetworkRequest extends Object implements android.os.Parcelable
Defines a request for a network, made through {@link NetworkRequest.Builder} and used to request a network via {@link ConnectivityManager#requestNetwork} or listen for changes via {@link ConnectivityManager#registerNetworkCallback}.

Fields Summary
public final NetworkCapabilities
networkCapabilities
The {@link NetworkCapabilities} that define this request.
public final int
requestId
Identifies the request. NetworkRequests should only be constructed by the Framework and given out to applications as tokens to be used to identify the request.
public final int
legacyType
Set for legacy requests and the default. Set to TYPE_NONE for none. Causes CONNECTIVITY_ACTION broadcasts to be sent.
public static final Creator
CREATOR
Constructors Summary
public NetworkRequest(NetworkCapabilities nc, int legacyType, int rId)

hide

        if (nc == null) {
            throw new NullPointerException();
        }
        requestId = rId;
        networkCapabilities = nc;
        this.legacyType = legacyType;
    
public NetworkRequest(NetworkRequest that)

hide

        networkCapabilities = new NetworkCapabilities(that.networkCapabilities);
        requestId = that.requestId;
        this.legacyType = that.legacyType;
    
Methods Summary
public intdescribeContents()

        return 0;
    
public booleanequals(java.lang.Object obj)

        if (obj instanceof NetworkRequest == false) return false;
        NetworkRequest that = (NetworkRequest)obj;
        return (that.legacyType == this.legacyType &&
                that.requestId == this.requestId &&
                ((that.networkCapabilities == null && this.networkCapabilities == null) ||
                 (that.networkCapabilities != null &&
                  that.networkCapabilities.equals(this.networkCapabilities))));
    
public inthashCode()

        return requestId + (legacyType * 1013) +
                (networkCapabilities.hashCode() * 1051);
    
public java.lang.StringtoString()


       
        return "NetworkRequest [ id=" + requestId + ", legacyType=" + legacyType +
                ", " + networkCapabilities.toString() + " ]";
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeParcelable(networkCapabilities, flags);
        dest.writeInt(legacyType);
        dest.writeInt(requestId);