views:

477

answers:

3

In the gui you can go to Settings->About Phone->Firmware Version and get 2.1 (or whatever). How do I do it from command line (or for a native application that needs to do it in run time ) ?

+1  A: 
Christopher
so what is this firmware version that I'm seeing in the GUI - I assumed it's the ndk version since numbers matched ("assumptions is the mother all f##kups..."). And do you know where it comes from ?
Dror Cohen
That's the Android OS version, which you can access in Java via `android.os.Build.VERSION.RELEASE`. You shouldn't need to look at that though; the `minSdkVersion` attribute in the manifest should be enough.
Christopher
Also when using OpenGL you can specify what version of OpenGL need at least: <uses-feature android:glEsVersion="0x00010001" /> for OpenGL 1.1 for example.
Soulreaper
@christopher: thanks for the information. How do I get the os version from my native application (at runtime) ?
Dror Cohen
As far as I'm aware, there is no such function to do so. The NDK is only for writing native libraries, not fully native Android applications. You'll always need a Java (dalvik) application to be running in order to utilise components written using the NDK, therefore any runtime version checks should be enforced via the AndroidManifest.xml file, or via Java code.
Christopher
A: 

Actually, that is a good question. If I want to enable compilations on both versions, I need to know what version of NDK I'm using, because the code tree structure is different between the 2 of them. I found that there is some kind of a variable they are using inside one of their internal makefiles, but it is the same for both versions.

I hope google will add a way to distinguish between the versions in the future.

Ofer
can you please share that variable and makefile ?
Dror Cohen
A: 

Since the app can be downloaded to various phones, the app need to get the firmware version at runtime in order to be able to pick different layouts.

Nils Thorell
this is not really an answer therefor it should be a comment. The app needs to know on which firmware version it is running but there is a difference between the ndk and the sdk. In the sdk you can get the firmware version via the Build class.
Janusz