我正在使用AQuery和 Tring 来使用这个库来下载文件,但我不明白如何使用它。
那是示例代码,但我不明白。
aq.download(String url, File target, Object handler, String callback)
如何定义“对象处理程序”和“字符串回调”?
你可以试试这个方法
File ext = Environment.getExternalStorageDirectory();
File target = new File(ext, "image/test.jpg");
aq.download(imageURL, target, new AjaxCallback<File>(){
public void callback(String url, File file, AjaxStatus status) {
if(file != null){
Toast.makeText(getApplicationContext(), "File:" + file.length() + ":" +file+"-"+status,
Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Download Failed", Toast.LENGTH_LONG).show();
}
}
});