Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set custom HTTP headers in the WebView

Tags:

android

I have to access a web page from within my application and, in order to have access to it, I need to set some custom HTTP headers. I want to use the WebViewclass in my activity but, as far as I can tell, it's not possible to set custom HTTP headers.

So is there a way of using the existing web browser (or WebView) with custom HTTP headers? My application targets Android 1.6.

Any idea how to solve this is greatly appreciated.

Thanks!

like image 440
Stelian Iancu Avatar asked Jan 05 '10 13:01

Stelian Iancu


1 Answers

use public void loadUrl (String url, Map extraHeaders) Since: API Level 8

Load the given url with the extra headers. Parameters url The url of the resource to load. extraHeaders The extra headers sent with this url. This should not include the common headers like "user-agent". If it does, it will be replaced by the intrinsic value of the WebView.

like image 57
Haitao Avatar answered Nov 15 '22 16:11

Haitao