The Request and BaseRequest now have several upload() and download() methods as alternatives to the send() methods. When using an upload or download API, the developer can pass in a ProgressListener which will be periodically called (currently called once per 2 KiB uploaded/downloaded) as the request is in progress. This allows the developer to monitor the progress when uploading or downloading large amounts of data.
The following types may be uploaded:
byte[]
String
File
InputStream
If the developer wants to have more control over reading in the download InputStream, they can use one of the send() methods instead of download(), and in their ResponseListener, they can retrieve the InputStream themselves with Response.getResponseByteStream(). Otherwise, using download() closes that InputStream, but Response.getResponseBytes() will still work.
Network Monitoring
The new NetworkMonitor class provides APIs for determining the current type of network connection available to the Android device, as well as monitoring changes in network connection with a NetworkConnectionListener. Developers can check if the current device has internet connection, determine the type (Wifi, mobile data, ethernet, etc), and the type of mobile data network (4G, 3G, or 2G).
Auto-retries
When making network requests, a new parameter in the Request constructor is available called autoRetries. This is the number of times the the Request class should resend the original request if it fails to receive a response, or receives a 504 gateway timeout.
Coverage increased (+17.3%) to 25.973% when pulling f82d1abc915e75beaa9dc3e372c6553ab1cdf63d on development into 600c3d69685a45781090606b74273dd27bceb415 on master.
Coverage increased (+17.3%) to 25.973% when pulling a934467c1eeaceed2ecd19dc214bf12908a65b0e on development into 600c3d69685a45781090606b74273dd27bceb415 on master.
Upload/download
The
Request
andBaseRequest
now have severalupload()
anddownload()
methods as alternatives to thesend()
methods. When using an upload or download API, the developer can pass in aProgressListener
which will be periodically called (currently called once per 2 KiB uploaded/downloaded) as the request is in progress. This allows the developer to monitor the progress when uploading or downloading large amounts of data.The following types may be uploaded:
byte[]
String
File
InputStream
If the developer wants to have more control over reading in the download
InputStream
, they can use one of thesend()
methods instead ofdownload()
, and in theirResponseListener
, they can retrieve theInputStream
themselves withResponse.getResponseByteStream()
. Otherwise, usingdownload()
closes that InputStream, butResponse.getResponseBytes()
will still work.Network Monitoring
The new
NetworkMonitor
class provides APIs for determining the current type of network connection available to the Android device, as well as monitoring changes in network connection with aNetworkConnectionListener
. Developers can check if the current device has internet connection, determine the type (Wifi, mobile data, ethernet, etc), and the type of mobile data network (4G, 3G, or 2G).Auto-retries
When making network requests, a new parameter in the
Request
constructor is available calledautoRetries
. This is the number of times the theRequest
class should resend the original request if it fails to receive a response, or receives a504
gateway timeout.