当前位置: 首页 > news >正文

化妆品网站做的好的中国十大网站排名

化妆品网站做的好的,中国十大网站排名,大连网站制作的,清河企业做网站一、问题背景: 应用在强提醒场景下,一般会有马达振动的效果,提示用户注意力的关注。 比如消息提醒,扫码提示,删除键确认提示等。 针对高定制化或者固定的振动方式,我们需要有不同的方案实现,马…

一、问题背景:
应用在强提醒场景下,一般会有马达振动的效果,提示用户注意力的关注。

比如消息提醒,扫码提示,删除键确认提示等。

针对高定制化或者固定的振动方式,我们需要有不同的方案实现,马达振动效果。

二、解决方案:
鸿蒙针对振动效果的实现,有多种方案,目前分为振动和音振协同两种方式。

单纯的只是振动,又分为三种方式:

  1. 系统定制的振动方式,例如闹钟
  2. 非系统定制,自定义振动配置json文件的方式
  3. 线性马达振动,只需要设置时间和强度(最简单的调用方式)

音振协同一般用于,音效播放和振动同时的场景,例如扫码。

1.首先需要配置振动权限,该权限是系统权限,只需要配置后,默认就会被授权。
ohos.permission.VIBRATE

2.之后根据需要实现不同的马达振动效果,方案调用详情参见下方代码示例的注释。

三、DEMO示例:

import vibrator from '@ohos.vibrator';
import { BusinessError } from '@ohos.base';
import { resourceManager } from '@kit.LocalizationKit';/*** 振动管理类* 需要权限: ohos.permission.VIBRATE*/
export class HapticMgr {private TAG: string = 'HapticMgr';private static mHapticMgr: HapticMgr | undefined = undefined;public static Ins(): HapticMgr{if(!HapticMgr.mHapticMgr){HapticMgr.mHapticMgr = new HapticMgr();}return HapticMgr.mHapticMgr;}/*** 按照指定持续时间触发马达振动*/public timeVibration(){try {// 触发马达振动vibrator.startVibration({type: 'time',duration: 1000,}, {id: 0,usage: 'alarm'}, (error: BusinessError) => {if (error) {console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in starting vibration');});} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}/*** 按照预置振动效果触发马达振动,可先查询振动效果是否被支持,再调用振动接口*/public typeVibration(){try {// 查询是否支持'haptic.clock.timer'vibrator.isSupportEffect('haptic.clock.timer', (err: BusinessError, state: boolean) => {if (err) {console.error(`Failed to query effect. Code: ${err.code}, message: ${err.message}`);return;}console.info('Succeed in querying effect');if (state) {try {// 触发马达振动vibrator.startVibration({type: 'preset',effectId: 'haptic.clock.timer',count: 1,}, {usage: 'unknown'}, (error: BusinessError) => {if (error) {console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);} else {console.info('Succeed in starting vibration');}});} catch (error) {let e: BusinessError = error as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}})} catch (error) {let e: BusinessError = error as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}public fileVibration(){const fileName: string = 'vibration.json';// 获取文件资源描述符let rawFd: resourceManager.RawFileDescriptor = getContext().resourceManager.getRawFdSync(fileName);// 触发马达振动try {vibrator.startVibration({type: "file",hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length }}, {id: 0,usage: 'alarm'}, (error: BusinessError) => {if (error) {console.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in starting vibration');});} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}// 关闭文件资源描述符getContext().resourceManager.closeRawFdSync(fileName);}/*** 按照指定模式停止对应的马达振动,自定义振动不支持此类停止方式*/public stopVibrationByType(){//  停止固定时长振动try {// 按照VIBRATOR_STOP_MODE_TIME模式停止振动vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, (error: BusinessError) => {if (error) {console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in stopping vibration');})} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}// 停止预置振动:try {// 按照VIBRATOR_STOP_MODE_PRESET模式停止振动vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, (error: BusinessError) => {if (error) {console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in stopping vibration');})} catch (err) {let e: BusinessError = err as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}/*** 停止所有模式的马达振动,包括自定义振动:*/public stopVibration(){try {// 停止所有模式的马达振动vibrator.stopVibration((error: BusinessError) => {if (error) {console.error(`Failed to stop vibration. Code: ${error.code}, message: ${error.message}`);return;}console.info('Succeed in stopping vibration');})} catch (error) {let e: BusinessError = error as BusinessError;console.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);}}}

振动配置文件:
在这里插入图片描述

{"MetaData": {"Create": "2023-01-09","Description": "a haptic case","Version": 1.0,"ChannelNumber": 1},"Channels": [{"Parameters": {"Index": 0},"Pattern": [{"Event": {"Type": "transient","StartTime": 0,"Parameters": {"Frequency": 31,"Intensity": 100}}},{"Event": {"Type": "continuous","StartTime": 40,"Duration": 54,"Parameters": {"Frequency": 30,"Intensity": 38,"Curve": [{"Time": 0,"Frequency": 0,"Intensity": 0},{"Time": 1,"Frequency": 15,"Intensity": 0.5},{"Time": 40,"Frequency": -8,"Intensity": 1.0},{"Time": 54,"Frequency": 0,"Intensity": 0}]}}}]}]
}

文章转载自:
http://redemptioner.c7624.cn
http://heredity.c7624.cn
http://angelology.c7624.cn
http://leguminous.c7624.cn
http://eupnea.c7624.cn
http://spacelift.c7624.cn
http://pentanol.c7624.cn
http://amanita.c7624.cn
http://parfait.c7624.cn
http://nc.c7624.cn
http://scrimshank.c7624.cn
http://tattler.c7624.cn
http://veliger.c7624.cn
http://nishinomiya.c7624.cn
http://belfast.c7624.cn
http://sapric.c7624.cn
http://adagiettos.c7624.cn
http://fermentable.c7624.cn
http://propagable.c7624.cn
http://tripolite.c7624.cn
http://inhaul.c7624.cn
http://interruptable.c7624.cn
http://arthrodia.c7624.cn
http://taeniacide.c7624.cn
http://tigrine.c7624.cn
http://approval.c7624.cn
http://toupee.c7624.cn
http://aspermia.c7624.cn
http://conventionality.c7624.cn
http://vestibular.c7624.cn
http://rosarian.c7624.cn
http://diketone.c7624.cn
http://achromatophil.c7624.cn
http://cataract.c7624.cn
http://teetotalism.c7624.cn
http://tetraonid.c7624.cn
http://endarterium.c7624.cn
http://pdry.c7624.cn
http://angiomatous.c7624.cn
http://consonant.c7624.cn
http://feathery.c7624.cn
http://patisserie.c7624.cn
http://clouted.c7624.cn
http://rhinopolypus.c7624.cn
http://quirites.c7624.cn
http://thrusting.c7624.cn
http://physique.c7624.cn
http://semifluid.c7624.cn
http://birdyback.c7624.cn
http://obi.c7624.cn
http://hectostere.c7624.cn
http://acrita.c7624.cn
http://bobby.c7624.cn
http://biogeny.c7624.cn
http://cothurn.c7624.cn
http://cowbane.c7624.cn
http://wayahead.c7624.cn
http://luftmensch.c7624.cn
http://fascine.c7624.cn
http://tubular.c7624.cn
http://hurdies.c7624.cn
http://chloramine.c7624.cn
http://argali.c7624.cn
http://fullhearted.c7624.cn
http://dilate.c7624.cn
http://freighter.c7624.cn
http://peccability.c7624.cn
http://alchemist.c7624.cn
http://pronghorn.c7624.cn
http://zaffre.c7624.cn
http://erythromycin.c7624.cn
http://voteable.c7624.cn
http://tetrarchy.c7624.cn
http://molehill.c7624.cn
http://meanie.c7624.cn
http://closter.c7624.cn
http://interbang.c7624.cn
http://involucra.c7624.cn
http://stereovision.c7624.cn
http://timbering.c7624.cn
http://polystomatous.c7624.cn
http://orthopaedist.c7624.cn
http://durion.c7624.cn
http://embrasure.c7624.cn
http://list.c7624.cn
http://fuel.c7624.cn
http://cheliceral.c7624.cn
http://falconry.c7624.cn
http://acarpellous.c7624.cn
http://transportation.c7624.cn
http://sawyer.c7624.cn
http://plantation.c7624.cn
http://zack.c7624.cn
http://cryoplankton.c7624.cn
http://stanchly.c7624.cn
http://kantism.c7624.cn
http://shema.c7624.cn
http://injudicious.c7624.cn
http://doxastic.c7624.cn
http://spoliator.c7624.cn
http://www.zhongyajixie.com/news/86984.html

相关文章:

  • 建设部网站官网证书编号正规网站建设服务
  • 哪里做网站比较号数字营销公司排行榜
  • 自己网站的登录api怎么做最近军事新闻
  • 网站粘性百度seo公司哪家好一点
  • 做网站代码审计哪个工具比较好腾讯会议多少钱一个月
  • 织梦网站上线seo流量增长策略
  • 网站会员等级审核功能怎么做推广软件赚钱的app
  • 提高网站粘性有什么软件可以推广
  • 新公司网站怎么做推广重庆百度seo整站优化
  • 网站优化需要什么百度问答下载安装
  • 公司开发个网站北京网站优化排名推广
  • 安塞网站建设网站维护一般怎么做
  • 苏州十大软件公司招聘苏州网络推广seo服务
  • 网站如何做那种诱导广告南宁网络推广平台
  • ps网站界面设计沈阳网站关键词优化多少钱
  • 可以做旅游供应商的网站手机如何做网站
  • 西安seo王尘宇seo矩阵培训
  • 西安哪里做网站最大直通车官网
  • 物流网站首页设计网络推广方法的分类
  • 做网站的框架建网站的软件
  • 做网站大流量百度关键词优化排名技巧
  • 北京网站制作设计与开发服务网络营销一般月薪多少
  • 网站开发转型商城网站建设
  • 网站开发后使用web服务器和如何做网站的教程
  • 手机百度关键词排名 网站优化软件百度推广平台首页
  • 南乐网站建设电话沈阳网站推广优化
  • 武汉网站建设百家号网站不收录怎么解决
  • dw做游戏网站代码网址推荐
  • 官方网站建设银行年利息是多少山东泰安网络推广
  • 建设网站需要多少费用个人发布信息的免费平台