首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    OpenHarmonyHarmonyOS震动模块的使用

    @ohos.vibrator (振动) 作者:坚果,公众号:”大前端之旅“,哔哩哔哩,OpenHarmony布道师,OpenHarmony校源行开源大使,51CTO博客专家博主,阿里云博客专家。...导入模块 使用的时候,需要先导入对应的模块 import vibrator from '@ohos.vibrator'; 添加权限 然后需要添加权限 FA "reqPermissions": [...示例: import vibrator from '@ohos.vibrator'; @Entry @Component struct VibPage { @State message: string...this.message) .fontSize(50) .fontWeight(FontWeight.Bold).onClick(()=>{ vibrator.vibrate...} } 需要注意的是在HarmonyOS应用中,ApI8的 接口声明文件编写错误,需要手动修改下SDK目录下接口声明文件,文件路径Sdk\openharmony\8\ets\api@ohos.vibrator.d.ts

    64120

    HarmonyOS学习路之开发篇—设备管理(控制类小器件)

    在调用Vibrator API时,请先通过getVibratorIdList接口查询设备所支持的振动器的ID列表,以免调用振动接口异常。...lightAgent.turnOn(lightId, lightEffect); // 关闭指定的灯 boolean turnOffResult = lightAgent.turnOff(lightId); } Vibrator...开发 场景介绍 当设备需要设置不同的振动效果时,可以调用Vibrator模块,例如,设备的按键可以设置不同强度和时长的振动,闹钟和来电可以设置不同强度和时长的单次或周期性振动。...void onStart(Intent intent) { super.onStart(intent); super.setUIContent(ResourceTable.Layout_vibrator_layout...boolean vibrateEffectResult = vibratorAgent.startOnce(vibratorId, VibrationPattern.VIBRATOR_TYPE_CAMERA_CLICK

    21970
    领券