android - Firebase storage handling network interruptions when download in progress -
i trying download files firebase storage. works when there stable internet connection. if internet connection lost while downloading content halfway, keeps trying download content. how detect if there no content being downloaded?
i have implemented onprogesslistener
of storagereference
. however, not sure how make use of detect if there no progress in download.
new onprogresslistener<filedownloadtask.tasksnapshot>() { @override public void onprogress(filedownloadtask.tasksnapshot tasksnapshot) { //what tasksnapshot detect if there no progress in download? } };
uploads, downloads , other operations intended automatically retry , shield temporary interruptions. there configurable timeout end (fail) operation if cannot transfer packet in time. can set with:
//if interrupted more 2 seconds, fail operation. firebasestorage.getinstance().setmaxuploadretrytimemillis(2000);
there different timeouts uploads, downloads , other operations.
with uploads, can attempt resume upload left off (if source file) if interrupted. need obtain "upload session uri" upload task.
task.addonfailurelistener(new onfailurelistener { @override public void onfailure(exception error) { uri uploadsession = task.getsnapshot().getuploadsessionuri(); //if want retry later, feed uri last parameter // putfile(uri, metadata, uri) } }
Comments
Post a Comment