안드로이드 테마설정: 두 판 사이의 차이

redbird's home
둘러보기로 이동 검색으로 이동
편집 요약 없음
편집 요약 없음
태그: 되돌려진 기여
1번째 줄: 1번째 줄:
<syntaxhighlight lang="python" line>
<pre>


fun setAppNightMode(mode: Int, context: Context) {
fun setAppNightMode(mode: Int, context: Context) {
12번째 줄: 12번째 줄:
}
}


</syntaxhighlight>
</pre>

2025년 12월 24일 (수) 09:00 판

fun setAppNightMode(mode: Int, context: Context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
        val uiModeManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
        uiModeManager.setApplicationNightMode(mode)
    } else {
        // Fallback for devices below Android 12 (S)
        // Use AppCompatDelegate.setDefaultNightMode() instead
        AppCompatDelegate.setDefaultNightMode(mode)
    }
}