Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Regular Contributor
Posts: 75
Registered: ‎11-30-2012
My Device: curve
My Carrier: airtel

Handling downloads in WebView



I am using webview to render a webpage in my app. The webpage asks for few credentials, once it is fine, it downloads a file.


When I use webview the downloaded file  is there in the data folder of the app, but the name is some random string,


Is there a way to handle this download so that I can get proper name.

Posts: 43
Registered: ‎01-05-2013
My Device: Dev Alpha
My Carrier: Telenor Hungary

Re: Handling downloads in WebView



I've searched, but not found the proper way, but I have an idea.


WebView has a signal, called: onNavigationRequested { }

Here is the link to its reference: 




So, this method will called, when any navigation is requested by the user. You can get the exact link from request.url property. And from here, you have 2 options. You can ignore the request, with the request.ignore() command, get the url from the request pointer, and send it to a C++ code, which will download the file, which is in the url. You can manage the whole process.


The another option is to let the browser download the file, but after the download you will rename it. The original file name is in the url, and you can get it.


Hope it helps!




If my post was helpful or it was the solution for Your problem, please don't forget to give me a like, and mark my post as a solution. Thanks!
Regular Contributor
Posts: 75
Registered: ‎11-30-2012
My Device: curve
My Carrier: airtel

Re: Handling downloads in WebView

Thanks for the inputs, will try the mechanism suggeted.