Issue
I am working on an android application. In my app i have to open some image and pdf from webservice.I could open the image by using following code.
HttpGet httpRequest = new HttpGet(URL);
httpRequest.addHeader("Accepts", "application");
httpRequest.addHeader("User-Authentication",
"c2hpbmVAaWxlYWZzb2x1dGlvbnMuY29tOnNoaW5laWxlYWY=");
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
.execute(httpRequest);
ANd now I have to open pdf in a webview.So I write the folowing code
WebView mWebView=new WebView(MyPdfViewActivity.this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
HashMap<String, String> map = new HashMap<String, String>();
map.put("Accepts", "application");
map.put("User-Authentication", "c2hpbmVAaWxlYWZzb2x1dGlvbnMuY29tOnNoaW5laWxlYWY=");
mWebView.loadUrl(URL,map);
But I am getting authentication header is not available error. Because of this problem my project is stuck. I find a same type problem here. check this answer here the accepted answer is "You would need to fetch the page yourself (e.g., via HttpClient) and load it into the WebView that way". How Can I do this?. Please help me to fix the issue friends.
Solution
Look into the documentation.
additionalHttpHeaders
The additional headers to be used in the HTTP request for this URL, specified as a map from name to value. Note that if this map contains any of the headers that are set by default by this WebView, such as those controlling caching, accept types or the User-Agent, their values may be overriden by this WebView's defaults.
Probably your User-Authentication header is also overriden.
Answered By - DragonWork
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.