You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
State your question
I want to treat TransferState.WAITING_FOR_NETWORK as a final state, like failed.
final TransferObserver observer = transferUtility.download(filePath, myOutfile);
observer.setTransferListener(new TransferListener() {
@UiThread
@Override
public void onStateChanged(int id, TransferState transferState) {
// it's on UI thread
switch (transferState) {
case WAITING:
case IN_PROGRESS:
break;
case PAUSED:
case RESUMED_WAITING:
break;
case WAITING_FOR_NETWORK:
// I want to treat this state as a final state
// after involes cancel, I will not receive CANCELED callback
transferUtility.cancel(id);
break;
case COMPLETED:
case CANCELED:
case FAILED:
break;
default:
break;
}
}
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
}
@Override
public void onError(int id, Exception e) {
}
});
In default, it will block when I turn off the internet, WAITING_FOR_NETWORK will be passed in onStateChanged.
But I want to treat this issue as a failed state. I tried like above, transferUtility.cancel(id) when the state becomes to WAITING_FOR_NETWORK, but I can't receive the next state 'CANCELED', anything wrong?
another question, when I turn on the internet, start a new task to download a new file, previous transferObserver will receive a onStateChanged, althoug I canceled it like above. What should I do to cancel the record and task? (and I dont need the previous tasks' callbacks)
thanks!
Environment(please complete the following information):
State your question
I want to treat
TransferState.WAITING_FOR_NETWORK
as a final state, like failed.In default, it will block when I turn off the internet,
WAITING_FOR_NETWORK
will be passed inonStateChanged
.But I want to treat this issue as a failed state. I tried like above,
transferUtility.cancel(id)
when the state becomes toWAITING_FOR_NETWORK
, but I can't receive the next state 'CANCELED', anything wrong?another question, when I turn on the internet, start a new task to download a new file, previous transferObserver will receive a
onStateChanged
, althoug I canceled it like above. What should I do to cancel the record and task? (and I dont need the previous tasks' callbacks)thanks!
Environment(please complete the following information):
implementation "com.amazonaws:aws-android-sdk-core:2.73.0"
Device Information (please complete the following information):
The text was updated successfully, but these errors were encountered: