Search code examples
androidandroid-version

how to get Android platform code-names like Honeycomb


In my application I want to show the Android OS code name of the device. i.e. I want to get the android OS code names like Honeycomb or Gingerbread pragmatically at run time from device.

Is there any way to get that codename sting itself? I want’s to show that name in one of the screens in my app.

I can compare like this and hardcode the string.

 if (Build.VERSION.SDK_INT==Build.VERSION_CODES.GINGERBREAD) {

    CodeName=”GINGERBREAD”

 } else if (Build.VERSION.SDK_INT==Build.VERSION_CODES.HONEYCOMB){

    CodeName=”Honeycom”
 }

But if tomorrow new version released then I’ve to change the code again. That’s why I am looking for some why to get the code name string itself instead of getting version number.

So can anyone suggest some way to get the device's OS code name like we get the OS version number?


Solution

  • There is no API in Android documentation to return the String of code name for you. You can obtain only VERSION NUMBER like 2.3, which you can show to users.