目录

CLASS info
public class Policy extends AbstractSafeParcelable
Describes a set of policies for publishing or subscribing to messages.

Nested Class Summary

TypeNameDesc
ClassPolicy.BuilderRepresents the builder class for Policy.

Constant Summary

TypeNameDesc
intPOLICY_FINDING_MODE_BROADCASTTo discover nearby devices, broadcasts a sharing code for other devices to scan.
intPOLICY_FINDING_MODE_SCANTo discover nearby devices, scans for other devices’ sharing codes.
intPOLICY_FINDING_MODE_DEFAULTTo discover nearby devices, broadcasts a sharing code and scans for other devices’ sharing codes.
intPOLICY_DISTANCE_TYPE_DEFAULTAllows messages to be transmitted over any distance.
intPOLICY_DISTANCE_TYPE_EARSHOTAllows messages to be transmitted only within the earshot.
intPOLICY_TTL_SECONDS_DEFAULTDefault TTL, in seconds.
intPOLICY_TTL_SECONDS_INFINITEIndefinite TTL, in seconds.
intPOLICY_TTL_SECONDS_MAXMaximum TTL, in seconds.

Field Summary

TypeNameDesc
public static final PolicyBLE_ONLYUses only BLE to discover nearby devices. The policy adopts TTL_SECONDS_INFINITE as the TTL and supports only #Get.
public static final CreatorCREATOR
public static final PolicyDEFAULTDefault policy, which is applicable to most apps. Currently, the default policy executes both broadcasting and scanning and uses Bluetooth to discover nearby devices, regardless of the distance.

Public Method Summary

ReturnMethod
booleanequals(Object other)
Checks whether any other object is the same as this object.
inthashCode()
Obtains the hash value.
StringtoString()
Converts an object into a readable character string.
voidwriteToParcel(Parcel dest, int flags)
Writes this value into a dest parcel.

Constants

Constant
public static final int POLICY_FINDING_MODE_BROADCAST
To discover nearby devices, broadcasts a sharing code for other devices to scan.
Constant value: 1
Constant
public static final int POLICY_FINDING_MODE_SCAN
To discover nearby devices, broadcasts a sharing code and scans for other devices’ sharing codes.
Constant value: 2
Constant
public static final int POLICY_FINDING_MODE_DEFAULT
To discover nearby devices, scans for other devices’ sharing codes.
Constant value: 0
Constant
public static final int POLICY_DISTANCE_TYPE_DEFAULT
Allows messages to be transmitted over any distance.
Constant value: 0
Constant
public static final int POLICY_DISTANCE_TYPE_EARSHOT
Allows messages to be transmitted only within the earshot.
Constant value: 1
Constant
public static final int POLICY_TTL_SECONDS_DEFAULT
Default TTL, in seconds.
Constant value: 240
Constant
public static final int POLICY_TTL_SECONDS_INFINITE
Indefinite TTL, in seconds. Note that only #Get supports this TTL type now.
Constant value: 0x7FFFFFFF
Constant
public static final int POLICY_TTL_SECONDS_MAX
Maximum TTL, in seconds.
Constant value: 86400

Public Methods

Method
public boolean equals(Object other)
Checks whether any other object is the same as this object.

Parameters

Parameter nameParameter desc
otherOther object.
Method
public int hashCode()
Obtains the hash value.
Method
public String toString()
Converts an object into a readable character string.
Method
public void writeToParcel(Parcel dest, int flags)
Writes this value into a dest parcel.

Parameters

Parameter nameParameter desc
destParcel to which this object is written.
flagsWriting mode.