2

In my app I am trying to display the Android version of the users current device as a textview however I have used the os.build.version.sdk and when I use that only the sdk code shows e.g 17 for Android 4.0.4 and I was trying get the Android version to show so is there a way to make an if or else statement to change the 17 into 4.0.4 at runtime. I have attached my java class below.

{
    TextView tv = (TextView) findViewById(R.id.display);
    tv.setText(android.os.Build.VERSION.SDK);
}
Cœur
  • 34,719
  • 24
  • 185
  • 251

3 Answers3

1

To display the Android release number, I would suggest to use android.os.Build.VERSION.RELEASE: http://developer.android.com/reference/android/os/Build.VERSION.html

{
    TextView tv = (TextView) findViewById(R.id.display);
    tv.setText(android.os.Build.VERSION.RELEASE);
}
Axel Cateland
  • 105
  • 1
  • 8
0

I think you can use VERSION.RELEASE field instead.

tv.setText(android.os.Build.VERSION.RELEASE + "");
Krishnabhadra
  • 33,955
  • 30
  • 116
  • 165
0

Try using

TextView tv = (TextView) findViewById(R.id.display);
tv.setText(String.valueOf(android.os.Build.VERSION.RELEASE));
Sankar V
  • 4,768
  • 3
  • 36
  • 56