Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android webview中的身份验证标头问题_Android_Web Services_Android Webview - Fatal编程技术网

Android webview中的身份验证标头问题

Android webview中的身份验证标头问题,android,web-services,android-webview,Android,Web Services,Android Webview,我正在开发一个android应用程序。在我的应用程序中,我必须从webservice打开一些图像和pdf。我可以使用以下代码打开图像 HttpGet httpRequest = new HttpGet(URL); httpRequest.addHeader("Accepts", "application"); httpRequest.addHeader("User-Authentication",

我正在开发一个android应用程序。在我的应用程序中,我必须从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);
WebView-mWebView=newwebview(MyPdfViewActivity.this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
HashMap=newHashMap();
map.put(“接受”、“申请”);
map.put(“用户身份验证”,“C2HPBMVAAWXLYWZB2X1DGLVBNMUY29TONOAW5LAWXLYWY=”);
loadUrl(URL,地图);
但我得到的认证头是不可用的错误。由于这个问题,我的项目陷于停顿。我在这里发现了一个相同类型的问题。 这里公认的答案是“您需要自己获取页面(例如,通过HttpClient)并以这种方式将其加载到WebView中”。我该怎么做?。 朋友们,请帮我解决这个问题。

请查看

附加HttpHeader

此URL的HTTP请求中要使用的附加头,指定为从名称到值的映射。请注意,如果此映射包含此WebView默认设置的任何标题,例如控制缓存、接受类型或用户代理的标题,则其值可能会被此WebView的默认值覆盖。


可能您的
用户身份验证
标题也被覆盖。

可能通过下载完整的pdf,然后使用Adobe Reader打开它?:)