Checking the extension of the file works in most cases, but not for all. Consider the following link:
http://t0.gstatic.com/images?q=tbn:ANd9GcTqqcX4SsdwgithvRcjQl_W3Hj-eIc_12FvdeGS2sO31uZ0F1HHqcdRKNo
Can I check from the URL if it is a link to an image? If not, is there a way to check after the page has loaded in the webview?
I know that I could download every page using HttpURLConnection, but I'm trying to avoid that approach.
Check Response HTTP Header Content-Type
. It will be one of the image
types. For Example, if I open the URL you have provided in Browser, will see Content-Type
as show below
Content-Type:image/jpeg
You can use HttpHead
method to fetch just the headers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.