Open mthurs13 opened 5 years ago
Did you implement
public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) {
// ...
}
and inside of that add a call to
AdvancedWebView.handleDownload(this, url, suggestedFilename)
as described in the README?
Can’t you check for runtime permissions as usual inside of onDownloadRequested
, and if granted, call AdvancedWebView.handleDownload
, otherwise, request the permission?
I already implemented code from example before But the app still crash when I trying to download a file, it wont popup the permission request So we have to manually enable WRITE_EXTERNAL_STORAGE permission from android app settings
public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) {
if (AdvancedWebView.handleDownload(this, url, suggestedFilename)) {
// download successfully handled
Toast.makeText(MainActivity.this, "Download Success!", Toast.LENGTH_LONG).show();
} else {
// download couldn't be handled because user has disabled download manager app on the device
Toast.makeText(MainActivity.this, "Download Failed!", Toast.LENGTH_LONG).show();
}
}
How to automatically popup the permission request? so we dont have to enable that permission manually from android app settings
Well, there don’t seem to be any permission checks and request in that excerpt as suggested, right?
Did you have any example code for permission checks and request?
Sure, these would be the standard Android runtime permissions:
https://developer.android.com/training/permissions/requesting
@mthurs13 , did you manage to get the download feature working? if so how ?
Sorry, I just start using android studio My App keep crash when I try to download some files due to no permission to access external storage
java.lang.SecurityException: No permission to write to /storage/emulated/0/Download/test.pdf: Neither user 10089 nor current process has android.permission.WRITE_EXTERNAL_STORAGE.
There's any way to force popup permission request when WRITE_EXTERNAL_STORAGE permission is disabled by user? so my App won't crash when i click download button without external storage permission
Sorry for my bad english Thank you