With android.hardware.Camera
, in order to have the camera output appropriately track the device movement, we need to hook up an OrientationEventListener>
use the formula below to get device rotation.
private int getOrientation(int rotation) {
return (ORIENTATIONS.get(rotation) + mSensorOrientation + 270) % 360;
}
SensorOrientation is a field assigned from
characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION)
Solution suggested by google engineer: yaraki
https://github.com/googlesamples/android-Camera2Basic/issues/24