| CLASS info |
| public class Data implements Parcelable |
| Represents the payload class. The payload needs to be sent and received in the same type. |
| Type | Name | Desc |
| class | Data.File | Local file. |
| class | Data.Stream | Data stream. |
| @interface | Data.Type | Payload type. |
| Return Type | Method Name |
| byte[] | asBytes() Obtains a payload of the byte type. An array of bytes is returned. |
| Data.File | asFile() Obtains a payload of the file type. An instance of Data.File is returned. |
| Data.Stream | asStream() Obtains a payload of the stream type. An instance of Data.Stream is returned. |
| Data | fromBytes(byte[] bytes) Creates a payload of the data packet type. An instance of Data is returned. |
| 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). |
| Data | fromFile(File javaFile) Creates a payload of the file type. An instance of Data is returned. |
| Data | fromStream(ParcelFileDescriptor pfd) Creates a payload of the stream type. An instance of Data is returned. |
| Data | fromStream(InputStream inputStream) Creates a payload of the stream type. An instance of Data is returned. |
| long | getId() Obtains the unique ID of the payload. |
| int | getType() Payload type. For details, please refer to Data.Type. |
| 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 name | Parameter desc |
| bytes | Byte array. |
Parameters
| Parameter name | Parameter desc |
| pfd | Instance of ParcelFileDescriptor. |
| Method |
| public static Data fromFile(File javaFile) |
| Creates a payload of the file type. An instance of Data is returned. |
Parameters
| Parameter name | Parameter desc |
| javaFile | Instance of javaFile. |
| Method |
| public static Data fromStream(ParcelFileDescriptor pfd) |
| Creates a payload of the stream type. An instance of Data is returned. |
Parameters
| Parameter name | Parameter desc |
| pfd | Instance 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 name | Parameter desc |
| inputStream | Instance 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. |