Possible Duplicate:
Retrieving Android API version programmatically
I am trying to retrieve the current API Version of the device my Application is Running. Is there a way i can get that and Store it on a String. This needs to Work on 1.5 Version and Up. Examples would be greatly appreciated. Thank you.
This example demonstrates how do I retrieve android API version programmatically. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.java
You can easily find the mapping from api level to android version in the android documentation. I believe, 8 is for 2.2, 7 for 2.1, and so on. Show activity on this post.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
To run the app from android studio, open one of your project's activity files and click Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
You can get it by calling Build.VERSION.SDK
.
From 1.6 on, you should use Build.VERSION.SDK_INT
instead
because Build.VERSION.SDK
is deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With