# seismic **Repository Path**: HarmonyOS-tpc/seismic ## Basic Information - **Project Name**: seismic - **Description**: openharmony device shake detection. It listens and identifies shakes on devices with appropriate hardware. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-15 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-drivers **Tags**: None ## README ## Seismic ## Introduction openharmony device shake detection. It listens and identifies shakes on devices with appropriate hardware. ### How it works? If the phone has an accelerometer, listen to sensor data modifications. Device is considered accelerating and is added to sample queue, if magnitude is greater than the acceleration threshold defined. Queue is considered shaking, if it has enough samples and more than 3/4 of those samples are accelerating. Toast can be displayed / other actions can be performed by overriding hearshake method. ## Usage Instruction Implement interface in the class and override method: implements ShakeDetector.Listener Create object and call method: ShakeDetector sd = new ShakeDetector(this); motionAgent = new CategoryMotionAgent(); sd.start(motionAgent); @Override public void hearShake() { ToastDialog toast = new ToastDialog(this); toast.setText("Don't shake me, Bro!"); toast.show(); } ## Installation instruction ### Method 1: Generate the .har package through the library and add the .har package to the libs folder. 1. Add the .har package to the lib folder. 2. Add the following code to the gradle of the entry: implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) ### Method 2: ```gradle allprojects { repositories { mavenCentral() } } dependencies { implementation 'io.openharmony.tpc.thirdlib:seismic:1.0.1' } ``` ## License ------- Copyright 2012 Square, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.