본문 바로가기
안드로이드

[android] getSerializableExtra deprecated

by 아이디생성자 2023. 3. 7.

함수를 하나 추가했다.

fun <T: Serializable> Intent.intentSerializable(key: String, clazz: Class<T>): T? {
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        this.getSerializableExtra(key, clazz)
    } else {
        this.getSerializableExtra(key) as T?
    }
}

댓글