Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for new phones running Android > 12 #98

Open
markalston opened this issue Sep 26, 2024 · 0 comments
Open

Fix for new phones running Android > 12 #98

markalston opened this issue Sep 26, 2024 · 0 comments

Comments

@markalston
Copy link

For some reason (my guess is that it is due to not calibrating the sensor) phones running android > 12 the sensor accuracy comes back as SensorManager.SENSOR_STATUS_ACCURACY_LOW.

This causes the shake detection to not work in the shake plugin due to the check in onSensorChanged in AccelListener.java

The following change fixes the issue and shake detection is now working great for me on all phones.

Change the line in plugins/cordova-plugin-device-motion/src/android/AccelListener.java:

if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {

to

if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_LOW) {

My guess is that while this works there is a better fix since the device-motion plugin is apparently depreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant