0

I made a condition that if the device doesn't have Device name it will get the Device model. But the thing is on some devices I'm getting the Device model even the device have Device name. Do you guys have an idea why I'm getting Device model not device name?

fun getDeviceName(): String =
    Settings.Global.getString(context.contentResolver, "device_name") ?: getDeviceNameIfNull()
KiritoCode
  • 26
  • 2
  • 5
  • Why do you think the device_name exists? That code will return the value if it does. Also, do not use "device_name". Use Settings.Global.DEVICE_NAME. That way if some OEM redefines the constant it will still work, and protects you against typos – Gabe Sechan Sep 06 '22 at 03:09

2 Answers2

0

Follow this code snippet, this might help you finding what you are looking for :

val model = Build.MODEL
val id = Build.ID
val manufacturer = Build.MANUFACTURER
val brand = Build.BRAND
val type = Build.TYPE
val user = Build.USER
val base = Build.VERSION_CODES.BASE
val incremental = Build.VERSION.INCREMENTAL
val sdk = Build.VERSION.SDK_INT
val board = Build.BOARD
val host = Build.HOST
Kishan Mevada
  • 662
  • 1
  • 6
  • 17
0

I think you're looking for this

val deviceModel = Build.MANUFACTURER + " " + Build.MODEL;
Mokhtar Abdelhalim
  • 232
  • 1
  • 3
  • 9