I use the sensorManager in my application,When I run the application for the first time,the sensorManager can't work correctly. The identify of direction X and direction Y change each other. Then I quit the application and enter application again,all the thing is correct!
The application's screenOrientation is 'landscape' , It's puzzle that when I change to 'portrait',everthing is ok,no any problems!
who can tell me how to resolve this problem?
The code:
SensorManager mSensorManager ;
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mSensorManager.registerListener(grGameRun,
SensorManager.SENSOR_ACCELEROMETER |
SensorManager.SENSOR_MAGNETIC_FIELD |
SensorManager.SENSOR_ORIENTATION,
SensorManager.SENSOR_DELAY_FASTEST);
public void onSensorChanged(int sensor, float[] values) {
synchronized (this) {
if (sensor == SensorManager.SENSOR_ORIENTATION) {
for (int i=0 ; i<3 ; i++) {
mOrientationValues[i] = values[i] ; //the problem place! the values[1] & values[2] are change each other
//when I enter the game for the first time
}
}
}
}
please help me !!!!!!!! thanks very much!!!!

