【发布时间】:2014-08-06 06:03:19
【问题描述】:
我正在使用 android 应用程序,我想从 android webview 中的链接打开 pdf。但是该链接已实现身份验证。我无法使用 pdf 打开该链接。但是如果我放置一个没有 pdf 的链接,我可以在 android webview 中看到该网页。所以身份验证工作正常。问题是当我将“https://docs.google.com/gview?embedded=true&url=”附加到 url 以打开 pdf 时。
请查看我的代码。
public class MainActivity extends Activity {
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview = new WebView(MainActivity.this);
webview.getSettings().setJavaScriptEnabled(true);
String url=
"https://docs.google.com/gview?embedded=true&url=" +"http://spahousingli.evero.com/SPADocuments/Forms/Clients/Admissions/ADM000000011.pdf";
webview.loadUrl(url);
webview.setWebViewClient(new WebViewClient() {
public void onReceivedHttpAuthRequest(WebView view,
android.webkit.HttpAuthHandler handler, String host,
String realm) {
handler.proceed("username", "password");
};
});
setContentView(webview);
}
}
【问题讨论】: