我有以下代码,但无法使用包含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")
}