@Override
    public void onConnect(int rst, HuaweiApiClient client) {
        if (client == null || !ApiClientMgr.INST.isConnect(client)) {
            HMSAgentLog.e("client not connted");
            onSnsGetMsgIntentResult(rst, null);
            return;
        }

        PendingResult<IntentResult> sendMsgResult = HuaweiSns.HuaweiSnsApi.getMsgSendIntent(client, msg, needResult);
        sendMsgResult.setResultCallback(new ResultCallback<IntentResult>() {
            @Override
            public void onResult(IntentResult result) {
                if (result == null) {
                    HMSAgentLog.e("result is null");
                    onSnsGetMsgIntentResult(HMSAgent.AgentResultCode.RESULT_IS_NULL, null);
                    return;
                }

                Status status = result.getStatus();
                if (status == null) {
                    HMSAgentLog.e("status is null");
                    onSnsGetMsgIntentResult(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 if (rstCode == SNSCode.OK) {
                    //回调GetMsgIntent结果
                    Intent nxtIntent = result.getIntent();
                    if (nxtIntent == null) {
                        HMSAgentLog.e("nxtIntent is null");
                        onSnsGetMsgIntentResult(HMSAgent.AgentResultCode.RESULT_IS_NULL, null);
                        return;
                    } else {
                        onSnsGetMsgIntentResult(rstCode, nxtIntent);
                        return;
                    }

                }else {
                    onSnsGetMsgIntentResult(rstCode, null);
                }
            }
        });
    }
@ Override public void onConnect ( int rst , HuaweiApiClient client ) { if ( client == null || ! ApiClientMgr . INST . isConnect ( client ) ) { HMSAgentLog . e ( "client not connted" ) ; onSnsGetMsgIntentResult ( rst , null ) ; return ; } PendingResult < IntentResult > sendMsgResult = HuaweiSns . HuaweiSnsApi . getMsgSendIntent ( client , msg , needResult ) ; sendMsgResult . setResultCallback ( new ResultCallback < IntentResult > ( ) { @ Override public void onResult ( IntentResult result ) { if ( result == null ) { HMSAgentLog . e ( "result is null" ) ; onSnsGetMsgIntentResult ( HMSAgent . AgentResultCode . RESULT_IS_NULL , null ) ; return ; } Status status = result . getStatus ( ) ; if ( status == null ) { HMSAgentLog . e ( "status is null" ) ; onSnsGetMsgIntentResult ( 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 if ( rstCode == SNSCode . OK ) { Intent nxtIntent = result . getIntent ( ) ; if ( nxtIntent == null ) { HMSAgentLog . e ( "nxtIntent is null" ) ; onSnsGetMsgIntentResult ( HMSAgent . AgentResultCode . RESULT_IS_NULL , null ) ; return ; } else { onSnsGetMsgIntentResult ( rstCode , nxtIntent ) ; return ; } } else { onSnsGetMsgIntentResult ( rstCode , null ) ; } } } ) ; }
HuaweiApiClient 连接结果回调

@param rst    结果码
@param client HuaweiApiClient 实例