Comments (3)
Thanks for your question!
You understood everything correctly and put this method in the right place. The only problem you have is the missing filename, right?
Well, that's easier than you might have thought:
Actually, you could just hard-code a filename into that method, which would look like this:
final String filename = "my-file.txt;
But this would always download and save any file under the name my-file.txt
. That's probably not what you want, right?
But you can do everything you want with this filename. For example, you could add the current timestamp at the beginning of that name so that files have unique names:
final String filename = System.currentTimeMillis()+" my-file.txt";
Alternatively, you could include your app's name, etc.
But another important thing that you'd probably want to change is the file extension. If you know what extension the file must have, that's great, then you can hard-code it as in the examples above. But often, it won't always be a text file, so you could detect the file extension from the MIME type that is passed as a method parameter:
final String filename;
if (mimetype.equals("image/jpeg")) {
filename = "my-photo.jpg";
}
else if (mimetype.equals("text/html")) {
filename = "my-document.html";
}
else {
// we didn't expect this MIME type and so we don't have any reasonable extension
filename = "my-file";
}
Hope that helps!
from android-advancedwebview.
Thanks for your suggestion it worked .:-)
But am unable to cancel the download once started .Can you please help on it.
from android-advancedwebview.
Glad that it worked :)
Cancelling any download is not currently possible when you let this library handle the downloads automatically. This would be possible in the future, but it will require some small changes to the source code:
Here and here, DownloadManager#enqueue()
is called, which returns a unique ID for each download. Those IDs would have to be stored and be passed to DownloadManager#remove()
when a future method (potentially named stopDownloads()
or something like this) would be called.
Is this really important? From what we know, cancelling downloads is only rarely needed.
from android-advancedwebview.
Related Issues (20)
- (Fullscreen) videos not working HOT 1
- Loading iframe inside webpage
- Is the XSS vulnerability fixed here? HOT 3
- Migrate to mavenCentral HOT 1
- Unable to view PDF From Amazon Service Url in AdvanceWebview. HOT 2
- Update AdvancedWebView and increase performance HOT 1
- Help to make downloads work in Jasonette-Android Advanced Webview Branch HOT 6
- Allow fullscreen mode ? HOT 1
- There is no loadHtml() command.
- Support to open google maps link with the google maps app HOT 1
- Datatables export buttons not working.
- Cannot cast my MainActivity into Advanced Webview Listener HOT 2
- Hide header and footer HOT 1
- Camera and audio permission issue
- Unresolved reference: im HOT 1
- Ask for photo on picture upload
- ANR HOT 1
- im.delight.android.webview.AdvancedWebView, was not found in the project or the libraries HOT 1
- How to disable webview navigate to another page?
- PDF URL does not get open
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-advancedwebview.