Hi I'm in the following situation: I'm using a WebView in an application to allow the download of files stored in a phpBB forum. I need to directly handle the downloads, saving the files to the application folders with their original names.
I'm bound to Android 2.2 Froyo, so no DownloadManager (if it even helps: http://www.vogella.de/blog/2011/06/14/android-downloadmanager-example/ ). So, the problem is that the download links for the files are like this: http://mywebsite.com/download/file.php?id=123 These links get caught by shouldOverrideUrlLoading(), but I can't handle the download in a custom way since there's no actual "file path and name on the server". I tried to use an HttpURLConnection and checked the returned headers. I located the file name in the "Content-disposition" header value, which is something like: attachment; filename*=UTF-8''the%20file%20name%20on%20the%20server.aaa Seems like phpBB generates this HTML response header here: https://github.com/phpbb/phpbb3/blob/develop/phpBB/download/file.php#L324 which refers to: https://github.com/phpbb/phpbb3/blob/develop/phpBB/includes/functions_download.php#L120 more specifically https://github.com/phpbb/phpbb3/blob/develop/phpBB/includes/functions_download.php#L191 So, WebView alone does not seem able to handle this kind of "Content- disposition" HTTP response header. It must be noted that these phpBB "file.php?id=123" links do work in the BrowserActivity that comes with each Android OS, and the correct file name pops up in the "save as..." dialog. ATM I'm digging in BrowserActivity.java present in Android's sourcecode repository... I saw that I might be good to go by using the InputStream returned by an HttpURLConnection, as in e.g.: http://getablogger.blogspot.com/2008/01/android-download-image-from-server-and.html http://www.helloandroid.com/tutorials/how-download-fileimage-url-your-device In the case that this is the only solution a question remains: how do I retrieve the original filename? Parsing the "Content-disposition" header value? :S any hint is appreciated! thanks -- Mathieu -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en