2012-08-08 3 views

답변

0

당신은 전화가이 개최되는 방법을 확인할 수 있습니다

Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
int rotation = display.getRotation(); 

그런 다음이 같은 방향을 확인할 수 있습니다

switch (rotation) 
{ 
    case Surface.ROTATION_90: 
     ... 
     break; 
    case Surface.ROTATION_180: 
     ... 
     break; 
    case Surface.ROTATION_270: 
     ... 
     break; 
    default: 
     ... 
     break; 
} 

(즉, 사전 API 8 버전을 참고 당신 ' d display.getRotation() 대신 display.getOrientation()을 사용해야합니다.

+0

이 코드를 사용하여 실시간으로 디스플레이 회전에 대한 데이터를 얻을 수 있습니까? –

+0

OrientationEventListener를 사용하여 방향 변경 내용을 듣고 현재 방향을 테스트 할 수 있습니다. http://developer.android.com/reference/android/view/OrientationEventListener.html – IncrediApp

관련 문제