public class MainActivity extends Activity
{
private TextView tv;
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout. activity_main);
tv=(TextView)
findViewById(R.id. tv);
}
/**
* 多线程断点下载
*/
public void click(View
view){
String url= "http://192.168.1.8:8080/img/e.jpg";
String path= "/mnt/sdcard/haha.exe";
//创建finalhttp 对象
FinalHttp http= new FinalHttp();
//1.要下载的文件路径 2.文件下载路径 3.数据回调
http.download(url, path, new AjaxCallBack()
{
@Override
public void onLoading(long count, long current)
{
tv.setText("下载进度:
" +current+"/"+count);
}
@Override
public void onSuccess(Object
t) {
Toast. makeText(getApplicationContext(), "下载成功.." ,
0).show();
super.onSuccess(t);
}
} );
}
}