当前位置:   article > 正文

android:angle="90",Android手机 G-sensor 倾斜度引出的开发问题

sensor 为什么不能转90度

srclinuxandroidframeworksbasepolicysrccomandroidinternalpolicyImplWindowOrientationListener.java

private static final int MAX_TILT = 75; //手机的倾斜度阈值,改大则手机倾斜度(相对于水平面)很小屏幕就会旋转,改大手机倾斜度需要很大,屏幕才会旋转。

函数public void onSensorChanged(SensorEvent event) {

// Calculate the tilt angle.

// This is the angle between the up vector and the x-y plane (the plane of

// the screen) in a range of [-90, 90] degrees.

// -90 degrees: screen horizontal and facing the ground (overhead)

// 0 degrees: screen vertical

// 90 degrees: screen horizontal and facing the sky (on table)

final int tiltAngle = (int) Math.round(

Math.asin(z / magnitude) * RADIANS_TO_DEGREES);//计算手机倾斜的角度。

// If the tilt angle is too close to horizontal then we cannot determine

// the orientation angle of the screen.

if (Math.abs(tiltAngle) > MAX_TILT) { //如果采集到的手机倾斜角度大于android系统设定的默认值MAX_TILT 就不会上报

if (LOG) {

Slog.v(TAG, "Ignoring sensor data, tilt angle too high: "

+ "tiltAngle=" + tiltAngle);

}

clearPredictedRotationLocked();

}

参考坐标系:

53b2a91329e32e9de0950eeb994abeb8.png

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号