App노자
[Android] android.os.Build (단말기 정보) 본문
1. android.os.Build란?
android.os.Build는 안드로이드 운영체제에서 제공하는 클래스로, 기기와 관련된 정보를 제공하는 정적 필드 및 메서드를 포함한다
이 클래스를 통해 앱은 기기의 다양한 속성과 정보에 접근할 수 있으며
시스템 속성에서 추출한 현재 빌드 중인 단말에 대한 정보로 제조사나 API레벨 OS버전 등을 알고 싶을 때 활용한다
https://developer.android.com/reference/android/os/Build
Build | Android Developers
developer.android.com
2. 사용방법
import android.os.Build
class DeviceInfo {
val brand: String
get() = Build.BRAND
val model: String
get() = Build.MODEL
val device: String
get() = Build.DEVICE
val product: String
get() = Build.PRODUCT
val versionRelease: String
get() = Build.VERSION.RELEASE
val versionSdkInt: Int
get() = Build.VERSION.SDK_INT
}
fun main() {
val deviceInfo = DeviceInfoProvider()
println("Brand: ${deviceInfo.brand}")
println("Model: ${deviceInfo.model}")
println("Device: ${deviceInfo.device}")
println("Product: ${deviceInfo.product}")
println("Android Version: ${deviceInfo.versionRelease}")
println("SDK Version: ${deviceInfo.versionSdkInt}")
}
'Android > AndroidStudio' 카테고리의 다른 글
[Android] TelephonyManager (단말기 정보) (0) | 2023.08.13 |
---|---|
[Android] Drawerlayout (드로어 레이아웃) (0) | 2023.08.12 |
[Android] Ripple Effect (0) | 2023.07.16 |
[Android] rounded corners (둥근 모서리) (0) | 2023.07.14 |
[Android] View Binding (뷰 바인딩) (0) | 2023.07.12 |