I have an app that receives push-notification, detects current device orientation (portrait/right landscape/left landscape) and takes a photo.
Orientation is used to set rotation for Camera.Parameters
.
I am using SensorManager.getRotationMatrix()
to calculate the orientation, but it requires values from geomagnetic sensors.
Lenovo S90-A
has no compass, so seems like there's no way for me to get these values.
I tried to use this code:
int rotation = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getRotation();
from my Service
, but it works only when device is on.
But if device is sleeping and I receive a push notification, then this method always returns Surface.ROTATION_0
.
Device will be fixed on the wall and is not supposed to move.
So, is there a way to detect current device orientation without compass?