Reputation: 73
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.
Upvotes: 0
Views: 649
Reputation: 18762
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
Upvotes: 1