我正在开发一个安卓应用程序。在我的应用程序中,我必须从 webservice 打开一些图像和 pdf。我可以使用以下代码打开图像。
HttpGet httpRequest = new HttpGet(URL);
httpRequest.addHeader("Accepts", "application");
httpRequest.addHeader("User-Authentication",
"c2hpbmVAaWxlYWZzb2x1dGlvbnMuY29tOnNoaW5laWxlYWY=");
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
.execute(httpRequest);
现在我必须在 webview 中打开 pdf。所以我编写了以下代码
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);
但我收到身份验证标头不可用错误。由于这个问题,我的项目被卡住了。我在这里发现了相同类型的问题。 在这里检查这个答案 ,接受的答案是“您需要自己获取页面(例如,通过 HttpClient)并以这种方式将其加载到 WebView 中”。我怎样才能做到这一点?。请帮我解决问题的朋友。