目录

CLASS info
public class Data implements Parcelable
Represents the payload class. The payload needs to be sent and received in the same type.

Nested Class Summary

TypeNameDesc
classData.FileLocal file.
classData.StreamData stream.
@interfaceData.TypePayload type.

Public Method Summary

Return TypeMethod Name
byte[]asBytes()
Obtains a payload of the byte type. An array of bytes is returned.
Data.FileasFile()
Obtains a payload of the file type. An instance of Data.File is returned.
Data.StreamasStream()
Obtains a payload of the stream type. An instance of Data.Stream is returned.
DatafromBytes(byte[] bytes)
Creates a payload of the data packet type. An instance of Data is returned.
DatafromFile(ParcelFileDescriptor pfd)
Creates a payload of the file type (called back by a ParcelFileDescriptor). The ParcelFileDescriptor can be obtained from a call to openFileDescriptor(Uri, String).
DatafromFile(File javaFile)
Creates a payload of the file type. An instance of Data is returned.
DatafromStream(ParcelFileDescriptor pfd)
Creates a payload of the stream type. An instance of Data is returned.
DatafromStream(InputStream inputStream)
Creates a payload of the stream type. An instance of Data is returned.
longgetId()
Obtains the unique ID of the payload.
intgetType()
Payload type. For details, please refer to Data.Type.

Public Methods

Method
public byte[] asBytes()
Obtains a payload of the byte type. An array of bytes is returned.
Method
public Data.File asFile()
Obtains a payload of the file type. An instance of Data.File is returned.
Method
public Data.Stream asStream()
Obtains a payload of the stream type. An instance of Data.Stream is returned.
Method
public static Data fromBytes(byte[] bytes)
Creates a payload of the data packet type. An instance of Data is returned.

Parameters

Parameter nameParameter desc
bytesByte array.
Method
public static Data fromFile(ParcelFileDescriptor pfd)
Creates a payload of the file type (called back by a ParcelFileDescriptor). The ParcelFileDescriptor can be obtained from a call to openFileDescriptor(Uri, String).

Parameters

Parameter nameParameter desc
pfdInstance of ParcelFileDescriptor.
Method
public static Data fromFile(File javaFile)
Creates a payload of the file type. An instance of Data is returned.

Parameters

Parameter nameParameter desc
javaFileInstance of javaFile.
Method
public static Data fromStream(ParcelFileDescriptor pfd)
Creates a payload of the stream type. An instance of Data is returned.

Parameters

Parameter nameParameter desc
pfdInstance of ParcelFileDescriptor. Nearby Connection will read data continuously from the ParcelFileDescriptor until it is closed.
Method
public static Stream fromStream(InputStream inputStream)
Creates a payload of the stream type. An instance of Data is returned.

Parameters

Parameter nameParameter desc
inputStreamInstance of InputStream.
Method
public long getId()
Obtains the unique ID of the payload.
Method
public int getType()
Payload type. For details, please refer to Data.Type.