I use this good library for detect shake motion on android devices.
Everything is good! But on my phone (Sony Xperia P) receiving SMS cause my phone to vibrate and shake detected!
In some other phone like HTC Sensation XE, the problem doesn't exist.
Any suggestion?
Thanks is advance.
Accelerometer Sensors in Android devices are used to detect the orientation of the device. This helps the application change the orientation when tilted when set to auto-rotate. Moreover, multiple applications use data from accelerometer sensors for performing various actions.
This example demonstrates how to do I in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.
AccelerometerSensor. Non-visible component that can detect shaking and measure acceleration approximately in three dimensions using SI units (m/s2).
Replacing SensorManager.SENSOR_ACCELEROMETER
with Sensor.TYPE_ACCELEROMETER
in sensorMgr.getDefaultSensor
solved my problem!
The SensorManager.SENSOR_ACCELEROMETER
has been deprecated in API level 3 (Link).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With