download pdf using maneger..... android

webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { DownloadManager.Request request = new DownloadManager.Request( Uri.parse(url)); //Restrict the types of networks over which this download may proceed. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); //Set whether this download may proceed over a roaming connection. request.setAllowedOverRoaming(false); Toast.makeText(getApplicationContext(),url +" agent "+userAgent +" "+contentLength,Toast.LENGTH_LONG).show(); Log.d("show ",url +" agent "+userAgent +" "+contentLength); request.setTitle("JUST Notice.pdf"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! } request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "JUST_Admission Notice.pdf"); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); Toast.makeText(getApplicationContext(), "Downloading File ", //To notify the Client that the file is being downloaded Toast.LENGTH_LONG).show(); } });

Comments