After a long time I used WebView. so let me ask you what phase my problem is.
- I had Google for the Blob URL , but I hvnt found a solution OR Any hint, so I have to post the Question HERE.
- I have a WebView on the android side to download the website. On button on "SAVE-AS" to download an image .
-But when I try it on the Google Chrome app yes its working fine and will load correctly.
-No same scenario with WebView in my application in DownloadListener I got the blob url somehow
blob: http://-----cantshare-----.com/7e7452c8-62ca-4231-8640-0e9de715e073
So downloadmanger download nothing
Check code
webview = (WebView) findViewById(R.id.webview); WebSettings settings = webview.getSettings(); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setJavaScriptEnabled(true); webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); final ProgressDialog progressBar = ProgressDialog.show(this, "WebView Example", "Loading..."); webview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.i(TAG, "Processing webview url click..."); view.loadUrl(url); return true; } public void onPageFinished(WebView view, String url) { Log.i(TAG, "Finished loading URL: " + url); if (progressBar.isShowing()) { progressBar.dismiss(); } } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.e(TAG, "Error: " + description); } }); webview.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri webpage = Uri.parse(url); if (!url.startsWith("http://") && !url.startsWith("https://")) { webpage = Uri.parse("http://" + url); } DownloadManager.Request request = new DownloadManager.Request( webpage); request.setMimeType(mimetype); String cookies = CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); request.addRequestHeader("User-Agent", userAgent); request.setDescription("Downloading file..."); request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimetype)); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalFilesDir(Main2Activity.this, Environment.DIRECTORY_DOWNLOADS,".pdf"); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); Toast.makeText(getApplicationContext(), "Downloading File", Toast.LENGTH_LONG).show(); } });
Q1 -Can Anyone give a suggestion How do I download a file from a Blob URL?
Q2 - need to change server side?
Q3 - any other ways instead of Downloadermanager?
Edit
I tried .pdf /.png/.jpeg but no luck ; (
setDestinationInExternalFilesDir(Main2Activity.this, Environment.DIRECTORY_DOWNLOADS,".pdf");