Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#ActualSimonForsman

Posted 01 August 2012 - 07:52 AM

For compatibility issues, isn't there a way to detect if the Android OS my app is being run on is a version older than 3.X?

I used to know that in C++, when you're programming for certain OS, you can use something like this (And yes, I do know my macros are incorrect, but the point is given):

#if __WINDOWS__
#elseif __APPLE__
#elseif __LINUX__
#endif

Would it be possible to code something like this for Android?


Those are compile time macros so you'd rather want something similar to getVersionEx on Windows.

http://developer.and...ld.VERSION.html should do the trick.

only annoying part is that the SDK_INT field is only available in newer versions (API versions 4+ (Android 1.6 and up) , and the RELEASE field is a string that may contain non numbers (it can be 4.1b3 for example). (There is also a deprecated SDK field but i wouldn't recommend using that).

If you don't care about 1.5 and down you can just use the value in SDK_INT to see what features you'll have available.

#1SimonForsman

Posted 01 August 2012 - 07:43 AM

For compatibility issues, isn't there a way to detect if the Android OS my app is being run on is a version older than 3.X?

I used to know that in C++, when you're programming for certain OS, you can use something like this (And yes, I do know my macros are incorrect, but the point is given):

#if __WINDOWS__
#elseif __APPLE__
#elseif __LINUX__
#endif

Would it be possible to code something like this for Android?


Those are compile time macros so you'd rather want something similar to getVersionEx on Windows.

http://developer.android.com/reference/android/os/Build.VERSION.html should do the trick.

PARTNERS