开发者

How do I use the session in WebView in my other stuff (Android)?

开发者 https://www.devze.com 2022-12-23 13:04 出处:网络
The user must login through the WebView. Of course, the session is for that WebView. But, what if I need to make REST API calls during my Android application?

The user must login through the WebView. Of course, the session is for that WebView. But, what if I need to make REST API calls during my Android application?

Those REST API calls need the session to be authenticated , otherwise those will not work. Is there an开发者_如何学Cy way I can attach the cookies of WebView into everything I do in Android?


But, what if I need to make REST API calls during my Android application?

It is possible you can use CookieManager.getInstance() to get access to the cookie in your WebView, then add it to the HttpClient CookieStore. So long as you keep using that same instance of the HttpClient object, it will continue to use that same CookieStore and will use the cookie. However, if that cookie changes via WebView, you will need to go get it again. I have not tried this and do not know what problems you may encounter.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号