Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - shake detection

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.

like image 954
Hossein Avatar asked Oct 31 '13 12:10

Hossein


People also ask

How to detect shaking in Android Studio?

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.

How do I find a shake event?

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.

Which sensor can detect the shakes of a mobile device?

AccelerometerSensor. Non-visible component that can detect shaking and measure acceleration approximately in three dimensions using SI units (m/s2).


1 Answers

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).

like image 99
Hossein Avatar answered Oct 05 '22 23:10

Hossein