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] ;
}
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---