使用DownloadManager从Google驱动器下载Android文件

时间:2019-05-01 10:23:27

标签: android

我正在使用Android应用程序从我的Google云端硬盘帐户下载压缩文件。该文件加载5MB,但仿真器仅下载65KB。 根据讨论(Android download file from PHP server),这是一个Cookie问题,但我不知道如何添加Cookie。 这是我的代码。 谢谢。

void download(String url) {
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        request.setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOCUMENTS, "doc.zip");
        request.allowScanningByMediaScanner();
        DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        downloadManager.enqueue(request);
    }

0 个答案:

没有答案
相关问题