android - Webview没有加载pdf url
问题描述
我有以下代码,但无法使用包含 PDF 文件的 URL。
日志没有显示任何类型的错误。
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_webview)
webview.settings.javaScriptEnabled = true
webview.settings.allowFileAccessFromFileURLs = true
webview.settings.allowUniversalAccessFromFileURLs = true
webview.settings.allowContentAccess = true
webview.settings.allowFileAccess = true
webview.webViewClient = object : WebViewClient(){
override fun onPageFinished(view: WebView, url: String) {
Log.d("WEBVIEWWWWW", "onPageFinished")
}
/**
* Notify the host application that the WebView will load the resource
* specified by the given url.
*
* @param view The WebView that is initiating the callback.
* @param url The url of the resource the WebView will load.
*/
override fun onLoadResource(view: WebView, url: String) {}
override fun onReceivedError(view: WebView, request: WebResourceRequest, error: WebResourceError) {
super.onReceivedError(view, request, error)
Log.d("WEBVIEWWWWW", "onReceivedError")
}
}
webview.loadUrl("http://www.axmag.com/download/pdfurl-guide.pdf")
}
解决方案
推荐阅读
- c++ - 为什么不能读取文件(不显示数据)?
- python - 有没有办法在 PyTorch DataParallel 中处理与 batch_index 相关的数据
- python - 如何只打印 JSON 对象的一部分数据?
- c - osDelay() 等待时间不够
- google-apps-script - 带有 Bearer 令牌的 Google App 脚本 UrlFetchApp 但收到错误请求
- python - 如何根据具有外键关系的另一个模型更新 Django 模型的字段
- nlp - 为什么 Amazon Comprehend Medical 在一个文本简介中识别出药物实体,而在另一个文本简介中识别不出来?
- git - 如何 gitignore firebase 缓存?
- python - 在 Python 中使用随机模块获取唯一数字
- vert.x - Vertx:意外的垂直行为,端点触发两次