1 回答
TA贡献1818条经验 获得超7个赞
我认为您正在寻找的是在navigationDelegate#OnLoadRequest
private fun createNavigationDelegate() = object : GeckoSession.NavigationDelegate {
override fun onLoadRequest(session: GeckoSession, request: GeckoSession.NavigationDelegate.LoadRequest): GeckoResult<AllowOrDeny> {
return if (request.uri.startsWith("https://www.example.com/")) {
GeckoResult.fromValue(AllowOrDeny.DENY)
} else {
GeckoResult.fromValue(AllowOrDeny.ALLOW)
}
}
}
private fun setupGeckoView() {
geckoView = findViewById(R.id.geckoview)
val runtime = GeckoRuntime.create(this)
geckoSession.open(runtime)
geckoView.setSession(geckoSession)
geckoSession.loadUri(INITIAL_URL)
geckoSession.navigationDelegate = createNavigationDelegate()
}
如果您有任何其他问题,您也可以在他们的GitHub 存储库上打开一个问题。您可能感兴趣的另一个项目是Mozilla Android Components。
添加回答
举报