Java 从android中的webview获取响应
我正在使用一个支付网关(Voguepay),其中请求URL生成一个响应URL,我想在webview中重定向到该URL 我的webview代码Java 从android中的webview获取响应,java,android,android-webview,Java,Android,Android Webview,我正在使用一个支付网关(Voguepay),其中请求URL生成一个响应URL,我想在webview中重定向到该URL 我的webview代码 @SuppressLint("SetJavaScriptEnabled") protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webv
@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");
}
请求URL已成功加载并显示此URL
我想重定向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
}
});