更新时间:2024-01-24 GMT+08:00
分享

显示提示信息

ShowToast

接口描述

该接口用于显示toast。

注意事项

  1. 该接口为异步接口,返回值只代表接口是否调用成功,实际业务处理结果在对应的回调函数中返回。

方法定义

1
HWM_SDK_AGENT_API hwmsdk::HwmErrCode ShowToast(const HwmToastInfo* toastInfo);

回调函数

1
virtual void OnShowToastResult(hwmsdk::HwmErrCode ret, const char* reason) {};

参数描述

表1 参数说明

参数

是否必须

类型

描述

toastInfo

HwmToastInfo

toast提示信息。

表2 结构体HwmToastInfo参数说明

参数

类型

描述

content

char[]

提示内容。

duration

int

提示持续时间(单位:秒)。

表3 返回值

类型

描述

HwmErrCode

成功返回0,其他值表示失败。失败返回值见错误码参考

示例代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
/**
* 显示toast提示
*/
void demoShowToastDlg::OnBnClickedOk()
{
    hwmsdkagent::HwmToastInfo toastInfo{ 0 };
    std::string toastContent = "toastContent";
    strcpy_s(toastInfo.content, HWM_MAX_TOAST_CONTENT_LEN, toastContent.c_str());
    toastInfo.duration = 5;
 
    int ret = hwmsdkagent::ShowToast(&toastInfo);
    if (hwmsdk::HWM_COMMON_SUCCESS != ret)
    {
        AfxMessageBox(_T("show toast error"));
        return;
    }
}
分享:

    相关文档

    相关产品