
回复
1.在moudle级别下的build.gradle文件中添加依赖
// 添加maven仓库
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
2.在entry模块的build.gradle文件中,
// 添加依赖库
dependencies {
implementation 'com.gitee.chinasoft_ohos:sensey:1.0.1'
}
如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
Ohos library which makes playing with sensor events & detecting gestures a breeze.
The library is built for simplicity and ease of use. It eliminates most boilerplate code for dealing with setting up sensor based event and gesture detection on Ohos.
Supported gestures/events
Gesture | Methods | Usage |
---|---|---|
Flip | onFaceUp onFaceDown |
Link |
Light | onDark onLight |
Link |
Orientation | onTopSideUp onBottomSideUp onLeftSideUp onRightSideUp |
Link |
PinchScale | onScale onScaleStart onScaleEnd |
Link |
Proximity | onNear onFar |
Link |
Shake | onShakeDetected onShakeStopped |
Link |
Wave | onWave | Link |
Chop | onChop | Link |
WristTwist | onWristTwist | Link |
Movement | onMovement onStationary |
Link |
SoundLevel | onSoundDetected | Link |
RotationAngle | onRotation | Link |
TiltDirection | onTiltInAxisX onTiltInAxisY onTiltInAxisZ |
Link |
Scoop | onScooped | Link |
PickupDevice | onDevicePickedUp onDevicePutDown |
Link |
Steps | stepInformation | Link |
TouchType | onDoubleTap onScroll(direction) onSingleTap onSwipeLeft onSwipeRight onLongPress onTwoFingerSingleTap onThreeFingerSingleTap |
Link |
onActive()
in the ability/abilitySlice, call
Sensey.getInstance().init(context);
// *** IMPORTANT ***
// Stop Sensey and release the context held by it
Sensey.getInstance().stop();
ShakeDetector.ShakeListener shakeListener=new ShakeDetector.ShakeListener() {
@Override public void onShakeDetected() {
// Shake detected, do something
}
@Override public void onShakeStopped() {
// Shake stopped, do something
}
};
Sensey.getInstance().startShakeDetection(shakeListener);
If you want to modify the threshold and time before declaring that shake gesture is stopped, use
Sensey.getInstance().startShakeDetection(threshold,timeBeforeDeclaringShakeStopped,shakeListener);
Sensey.getInstance().stopShakeDetection(shakeListener);
CodeCheck代码测试无异常
CloudTest代码测试无异常
安全病毒安全检测通过
当前版本demo功能与原组件基本无差异
Licensed under the Apache License, Version 2.0, click here for the full license.