HTTP引用中的WebView - 机器人 [英] Http Referer in WebView - Android

查看:145
本文介绍了HTTP引用中的WebView - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发我的简单的应用程序,在web视图显示图像,我得到了一些问题。

While developing my simple app that is displaying images in WebView I get some problem.

该图像不能因为我重定向到另一个页面的加载。我发现这个问题,它是为我工作的一半。解决的办法是

The images can't be loaded because of redirect me to another page. I found the problem and it is working for me at half. The solution is

例如:

的WebView WW =新的WebView(本);

我尝试加载图像是这样的:

I try to load an image like this:

ww.loadUrl(http://i1.kwejk.pl/site_media/obrazki/92825-ism.jpg);

和因为重定向的图像无法加载。

and image can't be loaded because of redirection.

但是,当我加载图像是这样的:

But when i load an image like this:

地图extraHeaders =新的HashMap();             extraHeaders.put(Referer的,2); ww.loadUrl(http://i1.kwejk.pl/site_media/obrazki/92825-ism.jpg,extraHeaders);

Map extraHeaders = new HashMap(); extraHeaders.put("Referer", "2"); ww.loadUrl("http://i1.kwejk.pl/site_media/obrazki/92825-ism.jpg", extraHeaders);

这是工作的罚款。

而最大的问题是我加载web视图中约10张这样的:

And the biggest problem is that I'm loading about 10 images in WebView like this:

String data="<html><body><img src="link1" /><img src="link2" /><img src="link3" /></body></html>";

ww.loadData(data);

和问题是:是否有可能设置引用者,当我试图loadData,而不是使用loadURL

And the question is: Is there any possibility to set referer when I'm trying to loadData instead of loadUrl?

推荐答案

这是我很容易的解决方案,只是loaddatawithbaseurl

here is my very easy solution, just loaddatawithbaseurl

http://androidyou.blogspot.com/2011/06/how-to-set-android-webview-referrer.html

这篇关于HTTP引用中的WebView - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆