[英]Get callback from a url loading inside webview
I am loading an Url from that page, we do some action and redirect to a New page inside WebView. 我正在从该页面加载一个URL,我们执行一些操作并重定向到WebView内的New页面。 now I want to get Callback when redirected page finishes loading. 现在,我想在重定向页面完成加载后获取回调。
I have tried 我努力了
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
L.d(url);
if (url.contains("Thank-you")) {
Utility.showToast(TabsActivity.this, "Subscription Done");
}
}
and also override 并覆盖
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
L.d(url);
view.loadUrl(url);
return true;
}
but I am still not able to get the callback from URL. 但我仍然无法从URL获取回调。
a bit of guessing is needed here, but I still believe, that you are try to find the string "Thank-you" in the url, but the url is written in lower case. 这里需要进行一些猜测,但是我仍然相信,您正在尝试在URL中找到字符串“ Thank-you”,但是该URL用小写形式编写。 Also you could try using WebChromeClient and then the onProgressChanged method. 您也可以尝试使用WebChromeClient ,然后再使用onProgressChanged方法。
Regards Tarik. 问候塔里克。
Register WebViewClient on your webview to return page finish listerner like this: 在您的网络视图上注册WebViewClient以返回页面完成列表器,如下所示:
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.