简体   繁体   English

有没有办法在每次点击后检查 webview 的 url ? Android工作室

[英]Is there a way to check the url of a webview after every click? Android Studio

I want to make a webview that checks after every click if the url is still the same.我想做一个 webview,每次点击后检查 url 是否仍然相同。 If the url is not the same then the app should close.如果 url 不同,则应用程序应关闭。 Is this possible with a webview? webview 可以做到这一点吗?

That would be a weird way to do it.那将是一种奇怪的方式。 Instead, you should just override the WebViewClient's shouldInterceptRequest and shouldOverrideUrlLoading to disallow any requests to URLs you don't want to allow, so they can't leave your app.相反,您应该只覆盖 WebViewClient 的 shouldInterceptRequest 和 shouldOverrideUrlLoading 以禁止对您不想允许的 URL 的任何请求,因此它们不能离开您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM