4

I would like to know if there is any way to detect if an Android Device is running Android One

Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61

1 Answers1

2

try looking at this : https://developer.android.com/reference/android/os/Build.VERSION, specifically looking at BASE_OS

you could do something like this : Build.VERSION.BASE_OS to get the name of the BASE_OS, however it seems like that call is only available for api 23 and up.

enter image description here

EDIT On a custom OS this seems to return null or empty, really not sure if there's any way to do this actually. Don't shoot the messenger here, I was just trying what's in the docs :P

EDIT 2 after doing a bit of searching, you can do this :

String deviceName = android.os.Build.MODEL;

String deviceMan = android.os.Build.MANUFACTURER;

for my own device, android.os.Build.MANUFACTURER this will return : Xiaomi as manufacturer, along with the device type for model as : Redmi Note 7

: taken from here How to detect a mobile device manufacturer and model programmatically in Android?

Edit 3 closest solution I found was using android.os.Build fields, you will probably have to get the names of certain devices(you can use android.os.Build.DEVICE) and do logic specific to those names, can't really see a different solution for this currently... https://developer.android.com/reference/android/os/Build

very cool question though :)

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
  • Build.VERSION.BASE_OS won't work everytime, might return empty – Manoj Perumarath Jul 23 '19 at 09:51
  • why would it return empty @ManojPerumarath ? – a_local_nobody Jul 23 '19 at 09:53
  • Might be because it's **Android** @a_local_nobody – Manoj Perumarath Jul 23 '19 at 09:54
  • Is `Build.VERSION.BASE_OS` 100% trustable for this matter? The call being available only for apis 23 or greater doesn't seem to be a problem, as it matches the first release version of the Android One. – Augusto Carmo Jul 23 '19 at 09:54
  • if there's no other solution from someone else specifically with a problem related to my solution, i don't think there's any way of doing it which would be more reliable. simply stating what the documentation says, check it on a device to see if it works – a_local_nobody Jul 23 '19 at 09:56
  • This doesn't result to identify it's a pure OS/Android One – Manoj Perumarath Jul 23 '19 at 09:57
  • 1
    yeah, i actually dont know if my solution will work. mine finds the Base_OS, but i dont think it will work for a custom OS – a_local_nobody Jul 23 '19 at 10:02
  • Does anybody know what a device running Android One would return through that constant (`Build.VERSION.BASE_OS`)? Unfortunately I do not have one at hand right now :/ – Augusto Carmo Jul 23 '19 at 10:06
  • 1
    @AugustoCarmo i have a xiaomi and it returns null when i run that – a_local_nobody Jul 23 '19 at 10:07
  • @AugustoCarmo One logic is that, there are only a certain number of Pure OS devices, once you run the app you can check the manufacturer and model to find the device – Manoj Perumarath Jul 23 '19 at 10:19
  • @ManojPerumarath, thanks for the contribution :). I'm willing to find a way to do this without depending on a list of all Android One devices available in the market. Up until now, checking `Build.VERSION.BASE_OS` seems to be the most promising answer, but I still have to check if it's 100% reliable. – Augusto Carmo Jul 23 '19 at 10:24
  • @AugustoCarmo Can you please share the code? What is exactly the condition to check if it's Android One or not? – android developer Jul 21 '20 at 06:58
  • what Build.VERSION.BASE_OS returns on Android One? – nsk Feb 02 '21 at 16:32