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);
}
2

3 Answers 3

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);
}
0

I think you can use VERSION.RELEASE field instead.

tv.setText(android.os.Build.VERSION.RELEASE + "");
0

Try using

TextView tv = (TextView) findViewById(R.id.display);
tv.setText(String.valueOf(android.os.Build.VERSION.RELEASE));

Not the answer you're looking for? Browse other questions tagged or ask your own question.