首页 > 解决方案 > 在下载管理器通知中显示下载速度

问题描述

Q1。我是安卓新手。我正在尝试开发一个使用下载管理器的应用程序。我想显示连接的下载速度(移动/Wifi,无论用户连接和下载的连接)。我不知道如何实现这一点。

Q2。下载管理器没有通过本地地址(如 192.168)下载是否有任何问题。. /file_name.extn? 只有当数据打开时才会出现下载通知,但下载并不总是失败。服务器工作正常,在浏览器上工作。

我使用的代码:

        String url  =mainActivity_downloadLink.getText().toString();
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
        //request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
        request.setTitle("Testing ");
        request.setDescription("the file is downloading");
        request.allowScanningByMediaScanner();
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
         , request.setDestinationInExternalFilesDir(MainActivity.this,Environment.DIRECTORY_DOWNLOADS,""+System.currentTimeMillis());
        //request.setDestinationInExternalFilesDir(MainActivity.this,Environment.DIRECTORY_DOWNLOADS,URLUtil.guessFileName(url, contentDisposition, mimeType));
        DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
        downloadManager.enqueue(request);
    }

任何帮助提前感谢。


标签: androidnotificationsandroid-download-manager

解决方案


推荐阅读