Skip to content

Instantly share code, notes, and snippets.

@ivaniskandar
Created June 9, 2020 07:24
Show Gist options
  • Save ivaniskandar/080d4269a63c966b60a103ce5d65526f to your computer and use it in GitHub Desktop.
Save ivaniskandar/080d4269a63c966b60a103ce5d65526f to your computer and use it in GitHub Desktop.
Get device Samsung OneUI version
fun Context.getOneUiVersion(): Double {
if (!isSemAvailable()) {
return 1.0
}
val semPlatformIntField: Field = Build.VERSION::class.java.getDeclaredField("SEM_PLATFORM_INT")
val version: Int = semPlatformIntField.getInt(null) - 90000
return if (version < 0) {
1.0
} else {
((version / 10000).toString() + "." + version % 10000 / 100).toDouble()
}
}
private fun Context.isSemAvailable(): Boolean {
return packageManager.hasSystemFeature("com.samsung.feature.samsung_experience_mobile") ||
packageManager.hasSystemFeature("com.samsung.feature.samsung_experience_mobile_lite")
}
@nanggatal
Copy link

Screenshot_20210905-003913_Settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment