简体   繁体   English

如何正确从回收站视图行开始下载?

[英]How do I correctly start download from recycler view row?

Recycler view rows contain download buttons then when the user presses it download manager gets called to download the file and get the URI. 回收者视图行包含下载按钮,然后在用户按下时,将调用下载管理器以下载文件并获取URI。 This works but how do I handle when the user presses back or press home button? 这行得通,但是当用户按下或按下主页按钮时我该如何处理? And how should I show the progress of a file that's still being downloaded when the user returns to the activity (typically after minimizing)? 当用户返回活动时(通常在最小化之后),我应该如何显示仍在下载的文件的进度?

You could start intent service when download a file and show status bar notification during download process. 您可以在下载文件时启动意向服务,并在下载过程中显示状态栏通知。 This will save download process. 这将节省下载过程。

Another way is to cancel download process when you leave that screen it's downloading. 另一种方法是,当您离开该屏幕时,取消下载过程。 In that case you should stop downloading in Activity::onStop method 在这种情况下,您应该停止在Activity :: onStop方法中下载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM