Comments (8)
首先,感谢你的宝贵意见。周末比较忙,没来的急回复。在零碎的时间里仔细考虑了一下你的建议。
在java命名规则中以new打头的方法,newSomeThing(),都会返回一个SomeThing的对象。比如volley的newRequestQueue(...)返回一个RequestQueue对象,Executors.newFixedThreadPool(...)返回一个ThreadPoolExecutor对象。
在MultiThreadDownload这个项目中,最好是对DownloadManager维护一个单例,以便对下载进行控制以及下载状态的回调。
而在Volley中,Volley的Request是可以自定义的,而不同的Request可能差别很大。比如如果把下载图片的Request和web api的Request公用一个RequestQueue来进行调度,可能在某些情况下会有问题。所以Volley本身对于Request没有维护一个单例,而是把这个任务交给开发者来完成,显得更加灵活。
所以我会考虑改成:
DownloadManager.init(context);
DownloadManager.init(context, config);
from multithreaddownload.
点击暂停,就异常终止闪退了
from multithreaddownload.
@mattxzhang
可以提供一下机型么?
如果可以帮助我调试一下,告诉我具体什么错误?
当然,你直接修复pull request那就更好了。
from multithreaddownload.
机型是小米2,系统5.0.2,就是下载时点击暂停就异常终止了,你的代码暂时没看,只是先看下效果
from multithreaddownload.
刚又试了下,不是机型的问题,操作步骤就是频繁点击(暂停,开始),滚动,就闪退了,测试了其他手机都是如此
from multithreaddownload.
@mattxzhang
你的安装包是在论坛下载的还是在github的页面上下载的?论坛下载的可能版本有点旧。我这边测试没有问题。我手头mx5 5.0.1,galaxy nexus 4.3.2, huawei c8815 miui, huawei honor 6 4.4 都没问题。
from multithreaddownload.
github页面下载的demo.apk,只需要频繁点击下载-暂停,就崩溃了,很好复现
from multithreaddownload.
@mattxzhang
谢谢持续反馈,我今天用同事的MX4也测试到了。问题已经定位。
奇怪的是我的几个手机都没问题。
当时在设计“取消下载”和“暂停下载”这两个功能的时候。最初是使用信号量的,但是当HttpURLConnection 处于阻塞状态,使用信号量就没办法及时暂停回调。
所以,我尝试了一种很暴力的办法直接调用disconnect()来close HttpURLConnection 所以依赖的Socket,来catch相应的Exception再配合信号量来确认状态进行回调。测试下来,在我的四个手机上以及GenyMotion的虚拟机上也没有问题,回调很及时。没想到还是出了问题。
两周内我会重构一次,到时候api可能会有所调整。
再次感谢。
我已经将此问题移到 #25
from multithreaddownload.
Related Issues (20)
- 请问您是怎解决listview更新进度条错乱的问题的?
- some method on service which part of project used? HOT 1
- limit download count HOT 1
- App getting slow and crashed HOT 1
- Device hangs
- Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.aspsine.multithreaddownload.DownloadInfo.setAcceptRanges(boolean)' on a null object referenc
- i have one problem please help me HOT 4
- please update this version
- i get this error in Logcat sometimes!
- request feature
- DownloadException: java.net.SocketTimeoutException: Read timed out
- UnSupported response code:403 HOT 1
- Not working with m3u8 video url
- How to AddHeader to connection? HOT 2
- Download Failed if request does not contain Content-Length HOT 1
- 多线程下载时强退应用,重新打开应用重新下载,断点进度出错 HOT 1
- A feature: Support for saving in application cache folder or files folder HOT 1
- java.lang.NullPointerException: Attempt to invoke interface method 'void java.util.concurrent.Executor.execute(java.lang.Runnable)' on a null object reference
- error UnSupported response code:301
- video download HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multithreaddownload.