Memory

[ANDROID/KOTLIN] 태블릿 기기인지 코드로 확인하는 방법 본문

IT/ANDROID

[ANDROID/KOTLIN] 태블릿 기기인지 코드로 확인하는 방법

_JinHa_ 2021. 1. 23. 14:22
반응형
fun isTablet(context: Context): Boolean {
        val xlarge = context.resources
            .configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK === 4
        val large = context.resources
            .configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK === Configuration.SCREENLAYOUT_SIZE_LARGE
        return xlarge or large
    }

 

[참고]

 

출처 - 

 

stackoverflow.com/questions/16784101/how-to-find-tablet-or-phone-in-android-programmatically

 

How to find Tablet or Phone in Android , Programmatically?

My case is that the logic is same for both Phone and Tablet. But there is slight difference in the layout. And I tried with the following code public static boolean findoutDeviceType(Context conte...

stackoverflow.com

 

반응형