如何启用的Andr​​oid的WebView饼干? [英] How to enable cookies in android webview?

查看:159
本文介绍了如何启用的Andr​​oid的WebView饼干?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何启用Cookie在web视图?

how do i enable cookies in a webview?

我试图用

CookieManager.getInstance().setAcceptCookie(true);

之前调用WebView.loadUrl()和它不工作,我从一个网站上的HTML页面错误说饼干需要激活。

just before calling WebView.loadUrl() and it doesnt work as i get a html page error from a website saying cookies need to be enabled.

我不明白什么是如何cookieManager知道启用Cookie其中的WebView?

What i dont understand is how does cookieManager know which webview to enable cookies?

说,如果我有一个活动的两个webviews在屏幕上,我只希望那些webviews使用网站功能之一,怎么可能用那么CookieManager?

say if i had a activity with two webviews in the screen and i only wanted one of those webviews to enable cookies, how is that possible using a CookieManager?

我觉得我失去了一些东西?我找不到像webView.setCookieManager或Cookiemanager.setWebView(web视图)

i feel like i am missing something? i could not find a method like webView.setCookieManager or Cookiemanager.setWebView(webview)

感谢

推荐答案

CookieManager.getInstance() CookieManager 的实例,为你的整个应用程序。 因此,您可以启用或禁用cookie为所有的 webviews 的应用程序中。

CookieManager.getInstance() is the CookieManager instance for your entire application. Hence, you enable or disable cookies for all the webviews in your application.

通常情况下,它应该工作,如果你的web视图已初始化: <一href="http://developer.android.com/reference/android/webkit/CookieManager.html#getInstance%28%29">http://developer.android.com/reference/android/webkit/CookieManager.html#getInstance()

Normally it should work if your webview is already initialized: http://developer.android.com/reference/android/webkit/CookieManager.html#getInstance()

也许你叫 CookieManager.getInstance()setAcceptCookie(真); 在初始化之前,你的的WebView 的,这是问题

Maybe you call CookieManager.getInstance().setAcceptCookie(true); before you initialize your webview and this is the problem?

这篇关于如何启用的Andr​​oid的WebView饼干?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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