How to identify android phone flip 180 degrees

699 views Asked by At

I need to identify is mobile display faced upside or downside. So how can do that? In the start phone display upside then it down side(display to earth and sky). not rotating the screen by fliping the screen.

2

There are 2 answers

1
Blaze Tama On

Use getRotation method :

http://developer.android.com/reference/android/view/Display.html#getRotation

It will return either of 4 options : ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270

0
Hoan Nguyen On

Register for sensor TYPE_ACCELEROMETER. In the onSensorChanged

if (event.values[2] > 0)
{
    // screen up
}
else
{
    // screen down
}