@Override
    public void onConnect(int rst, HuaweiApiClient client) {

        HMSAgentLog.d("onConnect:" + rst);

        if (client == null || !ApiClientMgr.INST.isConnect(client)) {
            HMSAgentLog.e("client not connted");
            onPurchaseInfoResult(rst, null);
            return;
        }

        // 调用HMS-SDK getOrderDetail 接口
        PendingResult<PurchaseInfoResult> purchaseInfoPenddingResult = HuaweiPay.HuaweiPayApi.getPurchaseInfo(client, purchaseInfoReq);
        purchaseInfoPenddingResult.setResultCallback(new ResultCallback<PurchaseInfoResult>() {
            @Override
            public void onResult(PurchaseInfoResult result) {

                if (result == null) {
                    HMSAgentLog.e("result is null");
                    onPurchaseInfoResult(HMSAgent.AgentResultCode.RESULT_IS_NULL, null);
                    return;
                }

                Status status = result.getStatus();
                if (status == null) {
                    HMSAgentLog.e("status is null");
                    onPurchaseInfoResult(HMSAgent.AgentResultCode.STATUS_IS_NULL, null);
                    return;
                }

                int rstCode = status.getStatusCode();
                HMSAgentLog.d("status=" + status);
                // 需要重试的错误码，并且可以重试
                if ((rstCode == CommonCode.ErrorCode.SESSION_INVALID
                        || rstCode == CommonCode.ErrorCode.CLIENT_API_INVALID) && retryTimes > 0) {
                    retryTimes--;
                    connect();
                } else {
                    onPurchaseInfoResult(rstCode, result);
                }
            }
        });
    }
@ Override public void onConnect ( int rst , HuaweiApiClient client ) { HMSAgentLog . d ( "onConnect:" + rst ) ; if ( client == null || ! ApiClientMgr . INST . isConnect ( client ) ) { HMSAgentLog . e ( "client not connted" ) ; onPurchaseInfoResult ( rst , null ) ; return ; } PendingResult < PurchaseInfoResult > purchaseInfoPenddingResult = HuaweiPay . HuaweiPayApi . getPurchaseInfo ( client , purchaseInfoReq ) ; purchaseInfoPenddingResult . setResultCallback ( new ResultCallback < PurchaseInfoResult > ( ) { @ Override public void onResult ( PurchaseInfoResult result ) { if ( result == null ) { HMSAgentLog . e ( "result is null" ) ; onPurchaseInfoResult ( HMSAgent . AgentResultCode . RESULT_IS_NULL , null ) ; return ; } Status status = result . getStatus ( ) ; if ( status == null ) { HMSAgentLog . e ( "status is null" ) ; onPurchaseInfoResult ( HMSAgent . AgentResultCode . STATUS_IS_NULL , null ) ; return ; } int rstCode = status . getStatusCode ( ) ; HMSAgentLog . d ( "status=" + status ) ; if ( ( rstCode == CommonCode . ErrorCode . SESSION_INVALID || rstCode == CommonCode . ErrorCode . CLIENT_API_INVALID ) && retryTimes > 0 ) { retryTimes -- ; connect ( ) ; } else { onPurchaseInfoResult ( rstCode , result ) ; } } } ) ; }
Huawei Api Client 连接回调
@param rst 结果码
@param client HuaweiApiClient 实例