NetworkRequestpublic class NetworkRequest extends Object implements android.os.ParcelableDefines 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 | networkCapabilitiesThe {@link NetworkCapabilities} that define this request. | public final int | requestIdIdentifies 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 | legacyTypeSet 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)
if (nc == null) {
throw new NullPointerException();
}
requestId = rId;
networkCapabilities = nc;
this.legacyType = legacyType;
| public NetworkRequest(NetworkRequest that)
networkCapabilities = new NetworkCapabilities(that.networkCapabilities);
requestId = that.requestId;
this.legacyType = that.legacyType;
|
Methods Summary |
---|
public int | describeContents()
return 0;
| public boolean | equals(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 int | hashCode()
return requestId + (legacyType * 1013) +
(networkCapabilities.hashCode() * 1051);
| public java.lang.String | toString()
return "NetworkRequest [ id=" + requestId + ", legacyType=" + legacyType +
", " + networkCapabilities.toString() + " ]";
| public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeParcelable(networkCapabilities, flags);
dest.writeInt(legacyType);
dest.writeInt(requestId);
|
|