ibm-bluemix-mobile-services / bms-clientsdk-android-core

Core components of Bluemix Mobile Services Android SDK
Apache License 2.0
6 stars 11 forks source link

New APIs for uploading/downloading, network monitoring, and auto-retries #43

Closed AnthonyOliveri closed 7 years ago

AnthonyOliveri commented 7 years ago

Upload/download

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:

  1. byte[]
  2. String
  3. File
  4. 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.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+17.3%) to 25.973% when pulling f82d1abc915e75beaa9dc3e372c6553ab1cdf63d on development into 600c3d69685a45781090606b74273dd27bceb415 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+17.3%) to 25.973% when pulling a934467c1eeaceed2ecd19dc214bf12908a65b0e on development into 600c3d69685a45781090606b74273dd27bceb415 on master.