|Modifier and Type||Class and Description|
Thrown when an
|Constructor and Description|
|Modifier and Type||Method and Description|
Closes the source.
When the source is open, returns the
Opens the source to read the specified data.
Reads up to
addTransferListener, bytesTransferred, transferEnded, transferInitializing, transferStarted
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public ContentDataSource(Context context)
context- A context.
@Deprecated public ContentDataSource(Context context, @Nullable TransferListener listener)
context- A context.
listener- An optional listener.
public long open(DataSpec dataSpec) throws ContentDataSource.ContentDataSourceException
dataSpec- Defines the data to be read.
C.LENGTH_UNSET) this value is the resolved length of the request, or
C.LENGTH_UNSETif the length is still unresolved. For all other requests, the value returned will be equal to the request's
public int read(byte buffer, int offset, int readLength) throws ContentDataSource.ContentDataSourceException
readLengthbytes of data and stores them into
buffer, starting at index
readLength is zero then 0 is returned. Otherwise, if no data is available because
the end of the opened range has been reached, then
C.RESULT_END_OF_INPUT is returned.
Otherwise, the call will block until at least one byte of data has been read and the number of
bytes read is returned.
buffer- The buffer into which the read data should be stored.
offset- The start offset into
bufferat which data should be written.
readLength- The maximum number of bytes to read.
C.RESULT_END_OF_INPUTif no data is available because the end of the opened range has been reached.
@Nullable public Uri getUri()
Urifrom which data is being read. The returned
Uriwill be identical to the one passed
DataSpecunless redirection has occurred. If redirection has occurred, the
Uriafter redirection is returned.
Urifrom which data is being read, or null if the source is not open.
public void close() throws ContentDataSource.ContentDataSourceException