Android 如何使用DownloadManager下载base64映像?

Android 如何使用DownloadManager下载base64映像?,android,android-download-manager,Android,Android Download Manager,如何使用DownloadManager下载base64映像(我的意思是,映像必须在下载后在应用程序下载中显示(将base64转换为字节并保存在文件中)) 例如: 我需要从下一个html“从自定义浏览器加载图像。并加载与普通图像url完全相同的内容(供用户查看)。对于普通图像url,我使用DownloadManager: DownloadManager.Request request = new DownloadManager.Request(source); request.al

如何使用DownloadManager下载base64映像(我的意思是,映像必须在下载后在应用程序下载中显示(将base64转换为字节并保存在文件中))

例如: 我需要从下一个html
从自定义浏览器加载图像。并加载与普通图像url完全相同的内容(供用户查看)。对于普通图像url,我使用DownloadManager:

DownloadManager.Request request = new DownloadManager.Request(source);
        request.allowScanningByMediaScanner();
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
        request.setTitle(fileName);
        request.setDescription(fileName);
        DownloadManager dm = (DownloadManager) App.getInstance().getSystemService(Context.DOWNLOAD_SERVICE);
        dm.enqueue(request);

请尝试下载此图像。 uRl是图像uRl

public void downloadFile(String uRl) {
        File direct = new File(Environment.getExternalStorageDirectory()
                + "/MyBox");

        if (!direct.exists()) {
            direct.mkdirs();
        }

        DownloadManager mgr = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);

        Uri downloadUri = Uri.parse(uRl);
        DownloadManager.Request request = new DownloadManager.Request(
                downloadUri);

        request.setAllowedNetworkTypes(
                DownloadManager.Request.NETWORK_WIFI
                        | DownloadManager.Request.NETWORK_MOBILE)
                .setAllowedOverRoaming(false).setTitle("Demo")
                .setDescription("Something useful. No, really.")
                .setDestinationInExternalPublicDir("/MyFiles", "fileName.jpg");

        mgr.enqueue(request);

    }

请尝试下载此图像。 uRl是图像uRl

public void downloadFile(String uRl) {
        File direct = new File(Environment.getExternalStorageDirectory()
                + "/MyBox");

        if (!direct.exists()) {
            direct.mkdirs();
        }

        DownloadManager mgr = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);

        Uri downloadUri = Uri.parse(uRl);
        DownloadManager.Request request = new DownloadManager.Request(
                downloadUri);

        request.setAllowedNetworkTypes(
                DownloadManager.Request.NETWORK_WIFI
                        | DownloadManager.Request.NETWORK_MOBILE)
                .setAllowedOverRoaming(false).setTitle("Demo")
                .setDescription("Something useful. No, really.")
                .setDestinationInExternalPublicDir("/MyFiles", "fileName.jpg");

        mgr.enqueue(request);

    }
还需要清单中的权限:

<uses-permission android:name="android.permission.INTERNET" />

这很奇怪,但另一方面,它不起作用

还需要清单中的权限:

<uses-permission android:name="android.permission.INTERNET" />


这很奇怪,但另一方面它不起作用。

在源代码中,如果我们放置非远程URIF(scheme==null | | |(!scheme.equals(“http”)&&&!scheme.equals(“https”)),这个类(请求)会引发异常。在源代码中,这个类(请求)有什么问题如果在源代码中放置非远程uri–mlevytskiy 1小时前grepcode.com/file/repo1.maven.org/maven2/org.robolectric/…–mlevytskiy 1小时前如果(scheme==null | | |(!scheme.equals(“http”)&!scheme.equals(“https”))在源代码中放置非远程uri(scheme==null | | |则该类(请求)抛出异常(!scheme.equals(“http”)&&!scheme.equals(“https”))有什么问题?在源代码中,如果我们在1小时前放置了非远程uri–mlevytskiy–grepcode.com/file/repo1.maven.org/maven2/org.roblectric/…–如果(scheme==null | | |(!scheme.equals(“http”)&!scheme.equals)&!scheme.equals),则在1小时前抛出异常("https"))