![]() Request.addRequestHeader("User-Agent", downloadUserAgent) ÄownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE) tNotificationVisibility(_VISIBLE_NOTIFY_COMPLETED) tDownloadListener((url, userAgent, contentDisposition, mimeType, contentLength) -> WebView webView = findViewById(R.id.web_view) Get DownloadManager system service and start the download.Also set the User-Agent to maintain consistency with requests sent by WebView and make notification show when the download completes so the user knows it's done. Construct a Request object and set the destination to the external Downloads directory.It is also a good idea to check if the file has an extension by checking if it contains a dot in its name, if it doesn't you can use MimeTypeMap to get extension based on the mimeType. ![]() ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |