I want to perform a certain task when a shake is detected through an accelerometer but the problem is every device's sensitivity level is different. For example: look at this code on sensor changed `
public void onSensorChanged(SensorEvent event) {
float[] values = event.values;
// Movement
float x = values[0];
float y = values[1];
float z = values[2];
//formula
float accelationSquareRoot = ((x * x + y * y + z * z)
/ (SensorManager.GRAVITY_EARTH * SensorManager.GRAVITY_EARTH));
float acc = accelationSquareRoot - 1;
String s1 = String.valueOf(acc);
//if I used a value 10 instead of 7 below it will be fine for samsung
phones but will not work on most nokia phones
if (acc >= 7){//perform certain task} }
For my Nokia 6.1 the shake detection is min 1 to max 10 and if the value is above 10 nothing will be detected, for Samsung Galaxy Note7, the detection level is from min 1 to max 30, which means every manufactures hardware is a bit different from others. If I set the value to 7, I have to shake hard on my Nokia 6.1 but on Samsung phones, value 7 is considered a very low sensitivity and the code will run even on touching the phone. I want the user's having various android devices to set the sensitivity level they want like small, medium, hard. What should I do to run this on devices from nearly 1300 brands with over 24,000 distinct android devices?