Questions
Questions

Reputation: 301

How to set cookies to a WebView?

I have a WebView that loads a certain URL site , I am able to add User Agent String using the following code. I need to set some cookies for the site to enable a mobile view format. Something like the picture below. I want to set the cookies before loading the site, so that on loading it shows up the way I want.

browser.getSettings().setUserAgentString("User Agent stuff");

enter image description here

The examples I found by searching are not straight forward and I couldn't figure it out. I hope I can get some assistance here, I will appreciate it!

Upvotes: 0

Views: 3098

Answers (1)

Wroclai
Wroclai

Reputation: 26925

Use the CookieManager API. Be sure that your input data into the setCookie() function is in the corresponding format in comparison to those cookies appearing in real web browsers/Wireshark etc.

Upvotes: 1

Related Questions