代码之家  ›  专栏  ›  技术社区  ›  Ricardo

Webview未加载pdf url

  •  0
  • Ricardo  · 技术社区  · 7 年前

    我有以下代码,但不使用包含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")
        }
    
    0 回复  |  直到 7 年前
    推荐文章