Android的 - 两个网页视图之间共享会话? [英] android - share session between two webviews?

查看:212
本文介绍了Android的 - 两个网页视图之间共享会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,可以有人请解释如何 CookieManager.getInstance()工作?我真的不明白我怎么可以从网页视图获取会话?比方说,如果我有这样的

first of all, can someone please explain how does CookieManager.getInstance() work? I don't really get how I can get the session from webview? Lets say if I have this

CookieSyncManager.createInstance(WebviewPage.this);
CookieManager cookieManager = CookieManager.getInstance();

我得到一个名为类会话 WebviewPage ?但如果我叫我的实际的WebView 的WebView ,怎么能 cookieManager 获得的WebView 的会议?即使不谈,如果我有两个的WebView webview1 webview2 。我怎么知道它会被保存在 cookieManager ??

Do I get the session from the class named WebviewPage? but what if I named my actual WebView to webview, how can cookieManager get the session of webview? not even talk about if I had two WebView, webview1 and webview2. How do I know which session that was stored in cookieManager??

我的主要问题是...我有两个活动,并在每个活动一web视图。我怎样才能从活动A获取会话,并把它传递给web视图中的活动B?

My main question is...I have two activities and one webview in each activity. How can I get the session from Activity A and pass it to the webview in Activity B?

谢谢!

推荐答案

CookieManager 似乎是个单身,所以,当你调用的getInstance()你总是得到相同的实例。所以,如果网页流量1设置一些饼干上CookieManager,或者如果设置了使用你的自我<一个href=\"http://developer.android.com/reference/android/webkit/CookieManager.html#setCookie%28java.lang.String,%20java.lang.String%29\"相对=nofollow>设置cookie的,所有其他网页视图应该得到同样的Cookie也是如此。

CookieManager seems to be a singleton, so when you call getInstance() you always get the same instance. So if webview 1 set some cookies on the CookieManager, or if you set it your self using set Cookie, all other webviews should get the same cookies as well.

这篇关于Android的 - 两个网页视图之间共享会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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