我们在项目中添加了一个活动,用户可以通过该活动购买一些东西,我们打开客户在网页视图中提供给我们的URL。 他们使用ccavenus支付getway。 在购买完成后的某些手机上,ccavenus重定向网址会被卡住,并且它会在无限长的时间内显示微调器。 在一些手机上,URL重定向工作顺利,用户可以买东西。
你们能帮我们解决这个问题吗?这是我们的网络视图代码。
private void launchWebView(String URL)
{
webView.setInitialScale(1);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowContentAccess(true);
webView.setScrollbarFadingEnabled(false);
webView.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int newProgress) {
if(newProgress == 100){
mProgressBar.setVisibility(View.GONE);
}else{
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(newProgress);
}
}
});
webView.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view,String url){
return false;
}
//To Handle SSL Errors
@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("The site's security certificate is not trusted!");
builder.setPositiveButton("Proceed anyway", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
handler.proceed();
}
});
builder.setNegativeButton("Back To safety", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
handler.cancel();
}
});
final AlertDialog dialog = builder.create();
dialog.show();
}
});
webView.loadUrl(URL);
mProgressBar = (ProgressBar)findViewById(R.id.offer_page_progressbar);
mProgressBar.setMax(100);
}
答案 0 :(得分:0)
private void startWebView(String url) {
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
//Show loader on url load
@Override
public void onLoadResource(WebView view, String url) {
}
@Override
public void onPageFinished(WebView view, String url) {
try {
if (url.contains("/wallet-recharge/failed")) {
finishMethod();
} else if (url.contains("/wallet-recharge/pay-completed")) {
webview.clearHistory();
Intent broadcastIntent = new Intent();
broadcastIntent.setAction("com.package.ACTION_CLASS_CABILY_MONEY_REFRESH");
sendBroadcast(broadcastIntent);
finishMethod();
} else if (url.contains("/wallet-recharge/pay-cancel")) {
finishMethod();
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
});
//Load url in webView
webview.loadUrl(url);
}