我有一个URL(www.abc.com
),该URL是我在应用程序内的活动的Web视图中打开的。我想开发一个流程,以便当用户浏览Web视图内的URL到达Web视图内的特定URL时,假设www.abc.com/foo
,则应用程序应处理它并打开特定的活动。如何捕获URL并根据URL的当前值打开特定活动
任何帮助将不胜感激。在此先感谢
这对我有用
创建webClient
并重写onPageFinished
方法以在加载每个页面后获取URL的当前值
wv_content.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
Log.v("Current value of URL: ", URL)
//handle URL like open an activity based on the value of URL
handleCurrentUrl(url)
super.onPageFinished(view, url)
pb_loading.visibility = View.GONE
}
}