我想在应用程序内部提供自定义浏览器,以便用户可以在 GitHub.com 上通过授权。但是在WebView
中禁用了授权按钮。
我在 stackoverflow 上设置了其他问题的推荐标志,但这没有帮助。我的ViewModel
在下面,您可以看到我为WebView
设置的标志和客户端:
class LoginViewModel : ViewModel() {
var url: ObservableField<String> = ObservableField()
var isLoading: ObservableBoolean = ObservableBoolean()
val webViewClient: WebViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
view?.loadUrl(url)
return true
}
override fun onReceivedError(
view: WebView, request: WebResourceRequest,
error: WebResourceError
) {
super.onReceivedError(view, request, error)
isLoading.set(false)
}
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
isLoading.set(false)
}
}
val webChromeClient: WebChromeClient = WebChromeClient()
val webViewConfig: IWebViewConfig = object : IWebViewConfig {
override fun onConfig(webView: WebView) {
webView.settings.domStorageEnabled = true
webView.settings.databaseEnabled = true
webView.settings.javaScriptEnabled = true
webView.settings.loadWithOverviewMode = true
webView.settings.useWideViewPort = true
webView.settings.allowContentAccess = true
webView.settings.allowFileAccess = true
webView.settings.allowFileAccessFromFileURLs = true
webView.settings.allowUniversalAccessFromFileURLs = true
webView.settings.userAgentString = "Android"
}
}
fun onRefresh() {
isLoading.set(true)
url.notifyChange()
}
}
问题出在哪里?