我在看什么:
ExecutorService es = Executors.newSingleThreadExecutor();
es.submit(new Runnable() {
@Override
public void run() {
transferUtility = S3.getTransferUtility(getApplicationContext());
TransferObserver observer = transferUtility.upload(S3.BUCKET_NAME, file.getName(), file);
observer.setTransferListener(new TransferListener() {
@Override
public void onStateChanged(int id, TransferState state) {
if (TransferState.COMPLETED.equals(state)) {
}
Log.d(SERVICE_NAME, "[onStateChanged] ID: " + id + " --- State: " + state);
}
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
Log.d(SERVICE_NAME, "[onProgressChanged] ID: " + id + " --- bytesCurrent: " + bytesCurrent + " --- BytesTotal: " + bytesTotal);
}
@Override
public void onError(int id, Exception ex) {
ex.printStackTrace();
Log.d(SERVICE_NAME, "[onError] ID: " + id);
}
});
}
});
}
但它仍然并行运行
有没有办法在没有创建一个CallBack / Interface来接收下载完成后启动它而不是启动下一个?