[英]Get response from a webview in android
I am using a payment gateway(Voguepay) where the request URL generates a response URL I want to redirect to that URL in webview
我的 webview 代码
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webveiw);
mWebView = findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.setWebViewClient(new MyWebViewClient());
// REMOTE RESOURCE
mWebView.loadUrl("https://voguepay.com/?p=linkToken&v_merchant_id=demo&\n" +
" memo=Payment for laptop&total=1000&merchant_ref=ref123&\n" +
" notify_url=https://example.com/notification.php&\n" +
" success_url=https://example.com/success.php&\n" +
" fail_url=https://example.com/fail.php&developer_code=ddd&cur=NGN");
}
我想重定向 webview 以加载上图中的链接
如果我正确理解了您的问题,您可以使用以下代码:
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url){
// do your handling codes here, which url is the requested url
// probably you need to open that url rather than redirect:
view.loadUrl(url);
return false; // then it is not handled by default action
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.