티스토리 뷰
private val autoRotateObserver = AutoRotateObserver(this, listener)
contentResolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION),
true, autoRotateObserver
)
override fun onDestroy() {
super.onDestroy()
contentResolver.unregisterContentObserver(autoRotateObserver)
}
class AutoRotateObserver(context: Context, listener: RotateConfigEventListener) : ContentObserver(null) {
private val mContext: Context = context
private val listener = listener
override fun onChange(selfChange: Boolean) {
super.onChange(selfChange)
// 설정값이 변경되면 호출됨
val autoRotateEnabled = Settings.System.getInt( mContext.contentResolver, Settings.System.ACCELEROMETER_ROTATION, 0) == 1
// Log.d(LOGTAG,"AutoRotateObserver onChange selfChange : ${selfChange} / ${autoRotateEnabled}")
listener.onChangeRotate(autoRotateEnabled)
}
}
autoRoateEnabled이 true면 회전 on, false면 off
'android' 카테고리의 다른 글
| di 패턴, dagger, hilt (0) | 2023.04.04 |
|---|---|
| retrofit으로, rx and coroutine (0) | 2023.02.03 |
| android mvvm 예제 (0) | 2023.01.30 |
| retrofit (0) | 2022.09.21 |
| by viewmodels() 쓰는법, (0) | 2022.08.18 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- insert
- spannableText
- ubunut 설치 link
- https://hwan-shell.tistory.com/244
- not found adb
- MongoDB
- 자바
- not working adb
- mongo db
- 차번호 정규표현식
- 구글 맵 선그리기
- React Native
- 데이터베이스
- 차번호 정규식
- 귀찮아;;
- ubunut android
- text 부분 색 칠하기
- mac android
- 구글 맵 경로 그리기
- Android
- https://medium.com/@limgyumin/%EC%BD%94%ED%8B%80%EB%A6%B0-%EC%9D%98-apply-with-let-also-run-%EC%9D%80-%EC%96%B8%EC%A0%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%EA%B0%80-4a517292df29
- react native state
- 함수형 코드
- 클래스형 코드
- 안드로이드
- not starting .bash_profile
- adb 환경변수
- 명령어
- nosql
- rn
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함
