问题描述
首先,可以有人请解释如何 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?
谢谢!
推荐答案
似乎是个单身,所以,当你调用的getInstance()你总是得到相同的实例。所以,如果网页流量1设置一些饼干上CookieManager,或者如果设置了使用你的自我设置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的 - 两个网页视图之间共享会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!