webView调起支付宝微信失败的解决办法
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
try {
if (url.startsWith(“weixin://wap/pay?”)) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}else if (url.startsWith(“alipays”)) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
} catch (Exception e) {
e.printStackTrace();
ToastUtils.showToast(WebViewActivity.this,“调用微信支付失败!”);
}
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@Override
public void onReceivedError(WebView view, WebResourceRequest request,
WebResourceError error) {
super.onReceivedError(view, request, error);
ToastUtils.showToast(WebViewActivity.this, "加载失败");
}
});