use of com.alipay.sdk.app.PayTask in project AgentWebX5 by Justson.
the class DefaultWebClient method isAlipay.
private boolean isAlipay(final android.webkit.WebView view, String url) {
try {
Activity mActivity = null;
if ((mActivity = mWeakReference.get()) == null)
return false;
/**
* 推荐采用的新的二合一接口(payInterceptorWithUrl),只需调用一次
*/
if (mPayTask == null) {
Class clazz = Class.forName("com.alipay.sdk.app.PayTask");
Constructor<?> mConstructor = clazz.getConstructor(Activity.class);
mPayTask = mConstructor.newInstance(mActivity);
}
final PayTask task = (PayTask) mPayTask;
boolean isIntercepted = task.payInterceptorWithUrl(url, true, new H5PayCallback() {
@Override
public void onPayResult(final H5PayResultModel result) {
final String url = result.getReturnUrl();
if (!TextUtils.isEmpty(url)) {
AgentWebX5Utils.runInUiThread(new Runnable() {
@Override
public void run() {
view.loadUrl(url);
}
});
}
}
});
LogUtils.i(TAG, "alipay-isIntercepted:" + isIntercepted + " url:" + url);
return isIntercepted;
} catch (Throwable ignore) {
if (AgentWebX5Config.DEBUG) {
ignore.printStackTrace();
}
}
return false;
}
Aggregations