dl: filename
parent
6f11b5eeba
commit
e8baff4273
|
@ -88,7 +88,7 @@ public class NativeX {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void downloadFromUrl(final String url) {
|
public void downloadFromUrl(final String url, final String filename) {
|
||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
DownloadManager manager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE);
|
DownloadManager manager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
DownloadManager.Request request = new DownloadManager.Request(uri);
|
DownloadManager.Request request = new DownloadManager.Request(uri);
|
||||||
|
@ -98,6 +98,9 @@ public class NativeX {
|
||||||
String cookies = android.webkit.CookieManager.getInstance().getCookie(url);
|
String cookies = android.webkit.CookieManager.getInstance().getCookie(url);
|
||||||
request.addRequestHeader("cookie", cookies);
|
request.addRequestHeader("cookie", cookies);
|
||||||
|
|
||||||
|
// Save the file to external storage
|
||||||
|
request.setDestinationInExternalPublicDir(android.os.Environment.DIRECTORY_DOWNLOADS, "memories/" + filename);
|
||||||
|
|
||||||
// Start the download
|
// Start the download
|
||||||
manager.enqueue(request);
|
manager.enqueue(request);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue