问题
My query is almost similar to one asked in the following link :
How to get file name when clicking on URL in webview
I don't want to use URLUtil for the reasons mentioned there.
Also, getting the file name using Content-Disposition header field does not work in my case.
I am using Android DownloadManager API for downloading file/images. I have to set destination filename using setDestinationInExternalPublicDir (String dirType, String subPath) method.
I have observed that DownloadManager provide name such as "downloadfile.jpeg", "downloadfile-2.jpeg" when any image url is used. I have looked into the DownloadManager source code and found COLUMN_LOCAL_FILENAME and COLUMN_TITLE that might be storing the name of file.
How can I get the file/image name as done in DownloadManager API ?
If not, is there any way I can detect that these urls does not contain filename at the end so that I can provide my custom name ?
来源:https://stackoverflow.com/questions/24577166/get-the-file-image-name-from-the-url-which-does-not-end-with-a-file-name-and-ext