0

를 항상 세로 방향으로 활동을 시작하지만 인식 초상화로,하지만 나는 방향적인 변화를 인식하고 싶다.안드로이드 : 나는 <code>setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);</code> 를 사용하는 경우 내가 활동이 잠겨 (장치가 풍경에서 개최되는 경우에도) 세로 방향</p> <p>항상 새로운 활동/의도를 시작하려는 방향 변경을

그래서 첫 번째 시작에서 활동을 만들 때 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);으로 전화해야한다고 생각합니다.이 제한을 제거하기 위해 수신기가 필요합니다.

그러나 어떤 방법으로 그렇게해야합니까? 생성자 또는 onCreate() 또는 다른 곳에 ???

+1

http://stackoverflow.com/questions/6293563/android-listen-for-orientation-change – Triode

답변

1
@Override 
    public void onConfigurationChanged(Configuration newConfig) { 
     // TODO Auto-generated method stub 
     super.onConfigurationChanged(newConfig); 

     System.out.println("on config change method called."); 

     if(Configuration.ORIENTATION_LANDSCAPE==newConfig.orientation) 
     { 

        //Portatrate to landscape... 
      System.out.println("on config change method called portraite mode."); 
     } 
     else if(Configuration.ORIENTATION_PORTRAIT==newConfig.orientation) 
     { 
      //Landscape to portraite.... 
      System.out.println("on config change method called landscape mode."); 
     } 
     }