Android: the range of z-value in the accelerometer sensor are different on different devices
- 阅读更多 关于 Android: the range of z-value in the accelerometer sensor are different on different devices
I want to detect if the device is facing up. (Not angled but flat to the ground facing up). On some devices for facing up, z value will return values between 9~10. (Most devices) However, on Nexus 7, for facing up, z value will return values between 6~8. My code was: if(z_value > 9.0) { // device facing up } else { // device is in angled } However, above code doesn't work anymore. Since Nexus7 doesn't reach z_value of 9. How can I detect if the device is facing (entirely) up or not. (not asking z_value > 0) My full code is below: @Override protected void onStart() { super.onStart(); try {