本文整理匯總了Java中android.hardware.SensorManager.getInclination方法的典型用法代碼示例。如果您正苦於以下問題:Java SensorManager.getInclination方法的具體用法?Java SensorManager.getInclination怎麽用?Java SensorManager.getInclination使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.SensorManager
的用法示例。
在下文中一共展示了SensorManager.getInclination方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSensorChanged
import android.hardware.SensorManager; //導入方法依賴的package包/類
public void onSensorChanged(SensorEvent event) {
int type = event.sensor.getType();
float[] data;
if (type == Sensor.TYPE_ACCELEROMETER) {
data = mGData;
} else if (type == Sensor.TYPE_MAGNETIC_FIELD) {
data = mMData;
} else {
// we should not be here.
return;
}
for (int i=0 ; i<3 ; i++)
data[i] = event.values[i];
SensorManager.getRotationMatrix(mR, mI, mGData, mMData);
// some test code which will be used/cleaned up before we ship this.
// SensorManager.remapCoordinateSystem(mR,
// SensorManager.AXIS_X, SensorManager.AXIS_Z, mR);
// SensorManager.remapCoordinateSystem(mR,
// SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, mR);
SensorManager.getOrientation(mR, mOrientation);
float incl = SensorManager.getInclination(mI);
if (mCount++ > 50) {
final float rad2deg = (float)(180.0f/Math.PI);
mCount = 0;
Log.d("Compass", "yaw: " + (int)(mOrientation[0]*rad2deg) +
" pitch: " + (int)(mOrientation[1]*rad2deg) +
" roll: " + (int)(mOrientation[2]*rad2deg) +
" incl: " + (int)(incl*rad2deg)
);
}
}