[Android] getRotation()
- Mobile/android
- 2011. 8. 3.
다른 블로그를 보면 어디에 넣어야 하는지, 적혀있지 않아서 -ㅅ-/ 살짝 놀랬습니다.
저는 화면 mode에 따라서 sensor의 Axis를 변경하려고 합니다. 그래서 다음과 같은 곳에 넣어두었습니다.
public void onSensorChanged(SensorEvent event) {
...
if (mGravity != null && mGeoMagnetic != null) {
...
// get Rotattion - 항상 90도로 나옴 ( 당연한 결과 Landscape 이니깐 )
WindowManager wm = (WindowManager)getSystemService( Context.WINDOW_SERVICE );
Display disp = wm.getDefaultDisplay();
int orientation = disp.getRotation();
Vanishing.getInstance().SetRotationofScreen( orientation );
switch( orientation )
{
case Surface.ROTATION_0:
Toast.makeText(MainActivity.this, "Rotation 0", Toast.LENGTH_SHORT ).show();
break;
case Surface.ROTATION_90:
Toast.makeText(MainActivity.this, "Rotation 90", Toast.LENGTH_SHORT ).show();
break;
case Surface.ROTATION_180:
Toast.makeText(MainActivity.this, "Rotation 180", Toast.LENGTH_SHORT ).show();
break;
case Surface.ROTATION_270:
Toast.makeText(MainActivity.this, "Rotation 270", Toast.LENGTH_SHORT ).show();
break;
}
}
}
그리고 출력은 Canvas 화면에 출력하였습니다.
그리고 딱히 Reference 를 달지 않겠습니다. 이번껀 T_T 창을 닫아버렸네요...
Reference
[1] Android Developers ( http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html ) ( 한글버전 : http://catnest.tistory.com/37 )
- 음...Sensor 를 다루는 개발자라면 꼭한번 읽어 보길 바랍니다.
[2] Being a Developer ( http://neodreamer.tistory.com/460 )
[1] Android Developers ( http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html ) ( 한글버전 : http://catnest.tistory.com/37 )
- 음...Sensor 를 다루는 개발자라면 꼭한번 읽어 보길 바랍니다.
[2] Being a Developer ( http://neodreamer.tistory.com/460 )
'Mobile > android' 카테고리의 다른 글
| [android] Conversion Euler to Matrix (1) | 2011.08.04 |
|---|---|
| [android] Conversion Euler to Matrix (0) | 2011.08.04 |
| [android] remapCoordinateSystem() (1) | 2011.08.02 |
| [android] Android rotate 시 Activity create 방지 (0) | 2011.07.29 |
| [Android] 메모리(SD카드)공간에 폴더 생성하기 (0) | 2011.07.29 |