Android中的Jsoup和DownloadManager错误

时间:2014-07-19 20:39:23

标签: android jsoup download-manager

我在我的应用中使用Jsoup和Download Manager。使用Jsoup时,DownloadManager无法下载。当我直接给下载管理器的URL时,它确实。我确信Jsoup工作正常。我的意思是问题是互联网连接或http连接问题。我该怎么办?代码部分如下。

Jsoup Part

Document doc = Jsoup.connect(begin).get();
title=doc.title();
end=doc.html().toString();

初始化下载管理器

public void initialize(){

    BroadcastReceiver receiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                long downloadId = intent.getLongExtra( DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                Query query = new Query();
                query.setFilterById(enqueue);
            }
        }
    };
    registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}

使用下载管理器

        dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        Request request = new Request(Uri.parse(url));
        request.setTitle(title);
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,title+".mp4");
        enqueue = dm.enqueue(request);

0 个答案:

没有答案