2

非常に具体的な問題があります。


デフォルトの向きが縦向きの Android デバイス (ほとんどの電話) の場合、デバイスの軸は次のように向きます。

電話の本来の縦向き

したがって、ベクトルと行列の計算を使用しようとしていて、デバイスの右、上、および出力のベクトルを見つける必要がある場合、次を使用できます。これは完全に機能します。

SensorManager.getRotationMatrix(tempRot, null, gravVals, geoMagVals);
SensorManager.remapCoordinateSystem(tempRot, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, rot);

Vector right  = new Vector(rot[0], rot[3], rot[6]); // the direction the right side of the phone is pointing
Vector up     = new Vector(rot[1], rot[4], rot[7]); // the direction the top side of the phone is pointing
Vector screen = new Vector(rot[2], rot[5], rot[8]); // the direction the screen is facing

デフォルトの向きが横向きの Android デバイス (Xoom など) の場合、デバイスの軸は次のように向きます。

タブレットの本来の横向き

したがって、電話で持っていたのと同じベクトルを実現するために、次を使用しますが、これには問題があります

SensorManager.getRotationMatrix(tempRot, null, gravVals, geoMagVals);
SensorManager.remapCoordinateSystem(tempRot, SensorManager.AXIS_X, SensorManager.AXIS_Y, rot); // this isn't really doing anything in this case

Vector right  = new Vector(rot[0], rot[3], rot[6]); // the direction the right side of the tablet is pointing
Vector up     = new Vector(rot[1], rot[4], rot[7]); // the direction the top side of the tablet is pointing
Vector screen = new Vector(rot[2], rot[5], rot[8]); // the direction the screen is facing

そのため、電話では問題なく動作しますが、タブレットでは左右および上下に移動する場合にのみ機能しますが、デバイスを回転させようとすると、突然データが意味をなさなくなります. 実際にタブレットの軸を変更して、デフォルトの縦軸(電話など)と一致させ、タブレットの持ち方に応じて4つの可能な方向を切り替えていると思います.

私のアプリケーションは、マニフェストに次のコードを使用して横向きモードでロックされています。

<activity android:screenOrientation="landscape" android:configChanges="keyboardHidden|orientation" .... />

そして、メソッドの推奨される実装:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}

明示的にそうしないように指示しているのに、なぜデバイスがまだ向きを変えているのか理解できません。アプリケーションは Android 2.2 で実行され、タブレットは 3.0.1 で実行されているため、マニフェストで「screenSize」フラグは必要ありません (私はそれを試しましたが、どちらも役に立ちませんでした)。この奇妙なデータが入り始めると、いくつかのイベント メソッドが呼び出されることが予想されますが、「onConfigurationChanged」も「onWindowAttributesChanged」も呼び出されておらず、「Display.getRotation()」と「Display.getOrientation()」は両方とも呼び出されています。常に0のまま。

タブレットの右、タブレットの上部、タブレットの画面が指している 3 つのベクトルを取得する方法を教えてください。また、タブレットの回転によって引き起こされている問題を停止する方法。

Xoomに関するnVidiaの情報は次のとおりです

4

0 に答える 0