多文件多线程断点下载,模仿慕课多线程多文件下载教程
2022-07-18 12:39:23 12.58MB 多线程 线程池
1
android多线程断点下载.rar
2022-07-05 18:07:08 76KB android
Android 多线程断点下载源码.zip
2022-06-14 21:04:02 88KB 源码
android多线程断点下载,完美封装,包括暂停功能。写好接口,android小白即能轻松上手。
2022-05-17 14:44:22 709KB android 多线程 断点 下载
1
摘要:Java源码,Android源码,多线程,断点下载  android多线程断点下载,通过本Android下载实例,可了解到以下知识技巧:实时得到文件下载的长度,设置获取实体数据的范围、获取文件已下载文件长度、原始文件长度、线程数、本地保存文件、缓存各线程下载的长度、每条线程下载的长度、获取线程数、获取文件大孝更新指定线程最后下载的位置、构建文件下载器、保存记录文件、根据响应获取文件大孝监听下载数量的变化,如果不需要了解实时下载的数量,可以设置为null、循环判断是否下载完毕等基础知识。   这里请注意,对于UI控件的更新只能由主线程(UI线程)负责,如果在非UI线程更新UI控件,更新的结
2022-05-17 14:42:47 83KB 移动开发源代码 Android源代码
1
根据网上寻找的资料,加上自己的整合,打包的一个Android多线程下载。可以实现断点下载,暂停继续取消下载,能够显示现在已完成大小,文件大小,完成度,下载速度等。使用方法如下: public class MainActivity extends Activity implements OnClickListener,DownloadListener{ private static final String TAG = "MainActivity"; private static final String SD_PATH = Environment.getExternalStorageDirectory().getPath(); private boolean isPause = false; private MultiThreadDownload multiThreadDownload ; private Button buttonDownload; private Button buttonCancel; private TextProgressBar progressBarTest;//可以使用普通的进度,该进度条是可以显示现在完成度 private TextView textInfo; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//布局文件就是两个简单的按钮一个用于暂停继续下载,一个用于取消任务,还有一个文本用于显示已完成,文件大小,下载完成度,下载速度等信息以及一个进度条。 //http://d1.apk8.com:8020/game/plantsvszombies2.apk buttonDownload = (Button)findViewById(R.id.buttonDownload); buttonDownload.setText("单击下载"); buttonDownload.setOnClickListener(this); progressBarTest = (TextProgressBar) findViewById(R.id.progressBarTest); textInfo = (TextView) findViewById(R.id.textInfo); buttonCancel = (Button) findViewById(R.id.buttonCancel); buttonCancel.setOnClickListener(this); } @Override public void onClick(View v) { String downloadUrl = "http://dldir1.qq.com/invc/qqpinyin/QQInput4.1_1133(1001).apk"; String savePath = SD_PATH+File.separator+"downloadHelper"+File.separator; String fileName = "QQInput.apk"; switch(v.getId()){ case R.id.buttonDownload: if(!isPause){ multiThreadDownload = new MultiThreadDownload(MainActivity.this,downloadUrl, savePath, fileName, this); multiThreadDownload.start(); buttonDownload.setText("下载..."); isPause = true; }else{ buttonDownload.setText("暂停..."); isPause = false; multiThreadDownload.onPause(); multiThreadDownload = null; } break; case R.id.buttonCancel: if(multiThreadDownload==null){ multiThreadDownload = new MultiThreadDownload(MainActivity.this,downloadUrl, savePath, fileName, this); } Log.d(TAG, ""+multiThreadDownload.isDownload()); if(multiThreadDownload.isDownload()){ multiThreadDownload.onCancel(); isPause = false; } multiThreadDownload = null; break; } } private Handler multiHandler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); if(msg.what==1){ Bundle data = msg.getData(); float downloadSpeed = data.getFloat("downloadSpeed"); boolean speedHigh = false; if(downloadSpeed>500){ speedHigh = true; downloadSpeed/=1024; } progressBarTest.setProgress(data.getInt("completedSize")); textInfo.setText(String.format("已完成:%.2fMB", data.getInt("completedSize")/1024f/1024)+"/"+ String.format("总大小:%.2fMB", data.getInt("fileSize")/1024f/1024)+"\n"+ String.format("进度:%.2f%%", data.getBoolean("isCompleted")?100.00:data.getFloat("downloadPercent"))+"/"+ String.format(speedHigh?"速度:%.2fM/S":"速度:%.2fKB/S", downloadSpeed)); if(data.getBoolean("isCompleted")){ buttonDownload.setText("下载完成"); textInfo.setText("下载完成"); } } } }; @Override public void onDownloading(boolean isCompleted,boolean isPause,boolean isCancel,int fileSize,int completedSize,int downloadedSize,float downloadPercent, float downloadSpeed) { Log.d("MainActivity", isCompleted+"||"+isPause+"||"+completedSize+"||"+downloadedSize+"||"+downloadPercent+"||"+downloadSpeed); Message message = Message.obtain(); message.what = 1; Bundle data = new Bundle(); data.putBoolean("isCancel", isCancel); data.putBoolean("isCompleted", isCompleted); data.putInt("fileSize", fileSize); data.putInt("completedSize", completedSize); data.putInt("downloadedSize", downloadedSize); data.putFloat("downloadPercent", downloadPercent); data.putFloat("downloadSpeed", downloadSpeed); message.setData(data); multiHandler.sendMessage(message); } @Override public void onBeforeDownload(boolean isCompleted,boolean isPause,boolean isCancel,int fileSize){ progressBarTest.setMax(fileSize); } @Override public void onAfterDownload(boolean isCompleted,boolean isPause,boolean isCancel,int fileSize){ } @Override public void onPause(boolean isCompelted,boolean isPause,boolean isCancel,int fileSize,int completedSize,int downloadedSize,float downloadPercent,float downloadSpeed){ textInfo.setText("暂停..."); Log.d(TAG, "暂停..."); } @Override public void onCancelDownload(){ progressBarTest.setProgress(0); textInfo.setText("下载取消"); buttonDownload.setText("重新下载"); } }
2022-03-10 19:42:52 22KB Android 多线程 下载
1
Java网络编程多线程断点下载带界面选择文件夹进度条
2021-12-30 17:55:52 24KB 网络编程
1
android多线程断点下载,支持暂停下载,自定义下载进度条
2021-10-29 11:45:26 1.74MB 多线程断点
1
文件下载,多线程下载。断点下载等简单封装的aar包
2021-10-14 12:04:41 59KB Android多线程断点下载
1
TCPIP传输文件支持多线程、断点
2021-07-01 17:00:41 5KB TCP/IP
1