Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Get Android parameters


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Dec 23, 2015 1:21 PM Last Post By: bernard roussely
bernard roussely

Posts: 106
Registered: 2/8/05
Get Android parameters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 23, 2015 12:23 AM
Hello,

This may not be new but I can't find any answer.

1) How can an app detect the Android version on which it is running using a C++ function (e.g., is there something like a GetAndroidVersion())?

2) How can an app detect a smartphone default language?

Thanks,

bernard
bernard roussely

Posts: 106
Registered: 2/8/05
Re: Get Android parameters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 23, 2015 5:43 AM   in response to: bernard roussely in response to: bernard roussely
Found an answer for 1) in Androiapi.JNI.Os.hpp

__interface INTERFACE_UUID("{1CEE3318-C68B-4A45-A09A-0584BFB9FA31}") JBuild_VERSIONClass : public Androidapi::Jni::Javatypes::JObjectClass
{
virtual Androidapi::Jni::Javatypes::_di_JString __cdecl _GetCODENAME(void) = 0 ;
virtual Androidapi::Jni::Javatypes::_di_JString __cdecl _GetINCREMENTAL(void) = 0 ;
virtual Androidapi::Jni::Javatypes::_di_JString __cdecl _GetRELEASE(void) = 0 ;
virtual Androidapi::Jni::Javatypes::_di_JString __cdecl _GetSDK(void) = 0 ;
virtual int __cdecl _GetSDK_INT(void) = 0 ;
HIDESBASE virtual _di_JBuild_VERSION __cdecl init(void) = 0 ;
__property Androidapi::Jni::Javatypes::_di_JString CODENAME = {read=_GetCODENAME};
__property Androidapi::Jni::Javatypes::_di_JString INCREMENTAL = {read=_GetINCREMENTAL};
__property Androidapi::Jni::Javatypes::_di_JString RELEASE = {read=_GetRELEASE};
__property Androidapi::Jni::Javatypes::_di_JString SDK = {read=_GetSDK};
__property int SDK_INT = {read=_GetSDK_INT};
};

CODENAME returns "rel" (does this mean "release"?)
INCREMENTAL returns "52"
RELEASE returns "5.1"
SDK returns 22
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Get Android parameters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 23, 2015 9:54 AM   in response to: bernard roussely in response to: bernard roussely
bernard wrote:

interface JBuild_VERSIONClass

http://developer.android.com/reference/android/os/Build.VERSION.html

CODENAME returns "rel" (does this mean "release"?)

Yes.

The current development codename, or the string "REL" if this is a release
build.

INCREMENTAL returns "52"

The internal value used by the underlying source control to represent this
build. E.g., a perforce changelist number or a git hash.

RELEASE returns "5.1"

The user-visible version string. E.g., "1.0" or "3.4b5".

SDK returns 22

This field was deprecated in API level 4. Use SDK_INT to easily get this
as an integer.

The user-visible SDK version of the framework in its raw String representation;
use SDK_INT instead.

--
Remy Lebeau (TeamB)
bernard roussely

Posts: 106
Registered: 2/8/05
Re: Get Android parameters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 23, 2015 12:39 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks.

What about the default language?

I found this in System.hpp:

extern DELPHI_PACKAGE UnicodeString __fastcall GetUILanguages(const Word LANGID);

bernard
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Get Android parameters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 23, 2015 1:06 PM   in response to: bernard roussely in response to: bernard roussely
bernard wrote:

What about the default language?

Use Android's Locale class:

http://developer.android.com/reference/java/util/Locale.html

There is a JLocale interface defined in the Androidapi.JNI.JavaTypes.hpp
header file:

_di_JLocale locale = TJLocale::JavaClass->getDefault();


TJLocale also exposes getAvailableLocales(), getISOCountries(), and getISOLanguages()
methods.

JLocale has several methods available, including getCountry(), getDisplayLanguage(),
getISO3Country(), getISO3Language(), getLanguage(), etc.

I found this in System.hpp:

extern DELPHI_PACKAGE UnicodeString __fastcall GetUILanguages(const
Word LANGID);

On Android, that function ignores the LangID parameter and returns the language
specified in the underlying Linux OS's "LANG" environment variable.

--
Remy Lebeau (TeamB)
bernard roussely

Posts: 106
Registered: 2/8/05
Re: Get Android parameters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 23, 2015 1:21 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Great. Thanks.
bernard
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02