通过Intent使用Basic Auth显示远程PDF [英] Showing remote PDF via Intent with Basic Auth
本文介绍了通过Intent使用Basic Auth显示远程PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试显示位于 http://myserver.com/my_file.pdf的PDF 一个>.该端点有一个基本的身份验证.我正在这样做:
I'm trying to show a PDF located in http://myserver.com/my_file.pdf. There is a basic auth for that endpoint. I'm doing this:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://myserver.com/my_file.pdf"));
Bundle bundle = new Bundle();
bundle.putString("Authorization", "Basic xxxxxxxxxxxxxxxxxxxx");
intent.putExtra(Browser.EXTRA_HEADERS, bundle);
startActivity(intent);
但是,当我调试服务器端时,请求中没有标头Authorization
,所以我得到401未经授权.
But when I debug the server side, there is no header Authorization
in the request so I get 401 Unauthorized.
我在做什么错了?
推荐答案
由于您无法共享确切的网址,因此建议您在应用的网络视图中打开该网址.
As you cannot share exact url, I would suggest you to open this inside a webview in your app.
webView.setJavaScriptEnabled(true);
webview.loadUrl(<URL>);
这篇关于通过Intent使用Basic Auth显示远程PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文