# 解码消息

Source: [https://docs.qualcomm.com/doc/80-PK177-134Y/topic/decoding_message.html](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/decoding_message.html)

void onValues(byte[] bytes, int size, int sensor_session_id)Copy to clipboard

此方法需要事先注册为事件回调，之后在发生 protobuf 编码字节数组事件时由 QESDK 传感器管理器触发。

可使用 Protobuf 生成的 API `parseFrom()` 将该字节数组事件数据转换为 Protobuf 客户端事件消息。

    sns_client_event_msg decode_request_msg=sns_client_event_msg.parseFrom(proto_message);
    //proto_message is byte arrayCopy to clipboard

事件可能是 `Activity_Recognition` 或 `SUID` 事件，具体通过事件 ID 来识别。

## SUID 事件消息

    sns_suid_msgid.SNS_SUID_MSGID_SNS_SUID_EVENT_VALUECopy to clipboard

对于 SUID 事件，SUID 数据嵌套在主事件消息中。要获取实际 SUID 数据，必须解析嵌套的 SUID 子消息。

    SnsStdType.sns_std_suid suid_event = null;
    suid_event=SnsSuid.sns_suid_event.parseFrom(decode_request_msg.getEvents(i).getPayload()).getSuid(0)Copy to clipboard

## AR 事件消息

    sns_activity_recognition_msgid.SNS_ACTIVITY_RECOGNITION_MSGID_SNS_AR_EVENT_VALUECopy to clipboard

对于 `Activity_Recognition`，AR 事件数据嵌套在主事件消息中。要获取实际 AR 数据，必须解析嵌套的 AR 子消息。

    sns_ar_event  ar_event = null;
    ar_event=SnsActivityRecognition.sns_ar_event.parseFrom(decode_request_msg.getEvents(i).getPayload());Copy to clipboard

**Parent Topic:** [编码和解码 protobuf 消息](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/encoding_and_decoding_protobuf_messages.html)

Last Published: Jun 22, 2023

[Previous Topic
请求消息](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/requesting_message.md) [Next Topic
示例代码](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/example_code_2.md)