1

I use Jsoup and Download Manager in my app. DownloadManager cannot download when I use Jsoup. When I give a url to DownloadManager directly,it does.I am sure that Jsoup works perfectly.I mean the problem is internet connection or http connection problem.What should I do? The code parts are below.

Jsoup Part

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

Initialize Download Manager

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));
}

Use Download Manager

        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);
Erkan Erol
  • 1,334
  • 2
  • 15
  • 32

0 Answers0