java.lang.Object | |
↳ | com.google.android.gms.nearby.connection.Payload |
A Payload sent between devices. Payloads sent as a particular type will be received as that same
type on the other device, e.g. the data for a Payload of type STREAM
must be
received by reading from the InputStream returned by asStream()
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Payload.File | Represents a file in local storage on the device. | ||||||||||
Payload.Stream | Represents a stream of data. | ||||||||||
Payload.Type | The type of this payload. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Non-null for payloads of type
BYTES . | |||||||||||
Non-null for payloads of type
FILE . | |||||||||||
Non-null for payloads of type
STREAM . | |||||||||||
Creates a Payload of type
BYTES for sending to another device. | |||||||||||
Creates a Payload of type
FILE (backed by a ParcelFileDescriptor )
for sending to another device; for example, the ParcelFileDescriptor obtained from a call to
openFileDescriptor(Uri, String) for a URI. | |||||||||||
Creates a Payload of type
STREAM (backed by a ParcelFileDescriptor ) for sending to another device; for example, the read side of a
ParcelFileDescriptor pipe to which data is being written by the MediaRecorder API. | |||||||||||
Creates a Payload of type
STREAM (backed by an InputStream ) for
sending to another device; for example, a PipedInputStream connected to a
PipedOutputStream to which data is being written. | |||||||||||
A unique identifier for this payload.
| |||||||||||
The type of this payload, one of
Payload.Type . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Creates a Payload of type FILE
(backed by a ParcelFileDescriptor
)
for sending to another device; for example, the ParcelFileDescriptor obtained from a call to
openFileDescriptor(Uri, String)
for a URI.
Parameters | |
---|---|
pfd |
ParcelFileDescriptor
|
Returns | |
---|---|
Payload |
Creates a Payload of type FILE
(backed by a File
) for
sending to another device. Note: The file will be saved in the remote device's Downloads folder
under a generic name with no extension. The client app on the remote device is responsible for
renaming this File
and adding an appropriate extension, if necessary, and all
this (and possibly additional) metadata should be transmitted by the local device out-of-band
(likely using a Payload of type BYTES
).
The client app must have any necessary permissions to read the Java file.
Parameters | |
---|---|
javaFile |
File
|
Returns | |
---|---|
Payload |
Throws | |
---|---|
FileNotFoundException |
Creates a Payload of type STREAM
(backed by a ParcelFileDescriptor
) for sending to another device; for example, the read side of a
ParcelFileDescriptor pipe to which data is being written by the MediaRecorder API.
Nearby Connections will read continuously from the ParcelFileDescriptor (for data to send) until it is closed.
Parameters | |
---|---|
pfd |
ParcelFileDescriptor
|
Returns | |
---|---|
Payload |
Creates a Payload of type STREAM
(backed by an InputStream
) for
sending to another device; for example, a PipedInputStream
connected to a
PipedOutputStream
to which data is being written.
Nearby Connections will read continuously from the InputStream (for data to send) until it is closed.
Parameters | |
---|---|
inputStream |
InputStream
|
Returns | |
---|---|
Payload |
A unique identifier for this payload.
Returns | |
---|---|
long |