This content has been marked as final. Show 5 replies
Thank for your reply Peter,
I´ve been pursuing your hint last night, but after some long hours analyzing this not sure if i know what you mean.
How can i replace the cookiehandler, its an abstract class, i can extended it like the default cookiemanager, but i can´t force webview to use it or can i?
Another thing, from this post:
"Vasiliy also explained that WebView will install it's own implementation of the CookieHandler, while retaining cookies put into the default one."
If this true, no matter what i do with the default cookiehandler this will not work, since webview will install it´s own implementation..
It seems that someone forgot that an more than 1 webview instance could run at the same time, because the problem only arises if running in the same VM, in different VM it´s behaves as it should.
If you have more toughts about this please share.
WebView installs its own handler only if the default one is null, otherwise it won't replace the already installed one. CookieHandler is static -- that's why two WebViews share the same instance -- so you don't have to do anything special to make WebView aware of the handler. It will just use whatever handler is installed, as any code that uses HttpURLConnection would do.
Still in your custom handler you'll have to somehow distinguish requests coming from two WebViews, that may be tricky given that the interface is simply
Map get(URI uri, Map<String,List<String>> requestHeaders);
Yes, that´s what i understood when i was reading the interface cookiehandler, static.
Very tricky stuff, and its really not my strong, cookies.
But i only want this to work in one website, so i know the ulr for the cookies, i could add some code to differentiate the cookies to be able to have 2 or more of the same, but the problem is how do i get them back in the get method..
Well, will think about this..If any thoughts about how to make this happen let me know.
Thank you again Peter, this was helpful.