AWS S3 Android SDK 2.11.0
I read release_v2.11.0 and release_v2.11.1 (released 23hs ago) CHANGELOGS and they indicate the next:
Amazon S3 (Enhancements): Introduced TransferNetworkLossHandler, a utility that listens for network connectivity changes. TransferNetworkLossHandler pauses the on-going transfers when the network goes offline and resumes the transfers that were paused when the network comes back online.
Amazon S3 (Bug fixes): Fixed a bug in TransferUtility where the state is not set to 'WAITING_FOR_NETWORK' when network goes offline during execution of transfers.
In your case u can include TransferNetworkLossHandler to avoid the error message and use TransferListener to detect state change to 'WAITING_FOR_NETWORK', 'FAILED' or 'ERROR' and notice user:
TransferObserver transferObserver;
transferObserver = transferUtility.upload(UPLOAD_FOLDER+fileName, fileToUpload);
transferObserver.setTransferListener(new UploadListener());
/**
* Upload listener to check transfer states and progress
*/
private class UploadListener implements TransferListener {
@Override
public void onStateChanged(int id, TransferState state) {
Log.d(TAG, "onStateChanged: " + id + ", " + state.toString());
// If upload error, failed or network disconnect
if(state == TransferState.ERROR || state == TransferState.FAILED || state == TransferState.WAITING_FOR_NETWORK){
// HERE end service and notice user !!!
}
}
@Override public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
float percentDonef = ((float) bytesCurrent / (float) bytesTotal) * 100; int percentDone = (int)percentDonef;
Log.d(TAG, "ID:" + id + " bytesCurrent: " + bytesCurrent + " bytesTotal: " + bytesTotal + " " + percentDone + "%");
}
@Override public void onError(int id, Exception ex) {
Log.e(TAG, ex);
}
}