خرید بک لینک

Vote count: 0

The download manager notification visibility is not working.

The file is downloaded directly to storage without notifying the download completion.

Here is my webview code:

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    // handle different requests for different type of files
    // this example handles downloads requests for .apk and .mp3 files
    // everything else the webview can handle normally
    if (url.endsWith(".mp3") || url.endsWith(".mp4") || url.endsWith(".pdf") || url.endsWith(".apk") || url.endsWith(".png") || url.endsWith(".jpg") || url.endsWith(".doc") || url.endsWith(".zip")
            || url.endsWith(".jar") || url.endsWith(".rar") || url.endsWith(".3gp") || url.endsWith(".docx") || url.endsWith(".txt") || url.endsWith(".gif") || url.endsWith(".avi")
            || url.endsWith(".flv")|| url.endsWith(".mkv") || url.endsWith(".mpeg")) {
        Uri source = Uri.parse(url);

        DownloadManager.Request request = new DownloadManager.Request(source);
        // appears the same in Notification bar while downloading
        request.setDescription("Description for the DownloadManager Bar");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            request.allowScaingByMediaScaer();

         request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        }
        else{
         request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
        }
        //save file with original name
        String fileExtenstion = MimeTypeMap.getFileExtensionFromUrl(url);
        String name = URLUtil.guessFileName(url, null, fileExtenstion);

        request.allowScaingByMediaScaer();
        // save the file in the "Downloads" folder of SDCARD
        request.setDestinationInExtealPublicDir(Environment.DIRECTORY_DOWNLOADS, name);
        // get download service and enqueue file
        DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
        manager.enqueue(request);

        Toast.makeText(getApplicationContext(), "Downloading ...", //To notify the Client that the file is being downloaded
                Toast.LENGTH_LONG).show();
    }
    else view.loadUrl(url);
    retu true;}

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 13 فروردين 1395 ساعت: 13:03

صفحه بندی