Stay organized with collections
Save and categorize content based on your preferences.
API Levels
Defines functions and constants for working with Android API levels.
Summary
Functions
|
android_get_device_api_level()
|
int
Returns the targetSdkVersion of the caller, or __ANDROID_API_FUTURE__ if there is no known target SDK version (for code not running in the context of an app).
|
Functions
android_get_device_api_level
Declared in android/api-level.h
int android_get_device_api_level()
Returns the targetSdkVersion
of the caller, or __ANDROID_API_FUTURE__
if there is no known target SDK version (for code not running in the context of an app).
The returned values correspond to the named constants in <android/api-level.h>
, and is equivalent to the AndroidManifest.xml targetSdkVersion
.
See also android_get_device_api_level().
Available since API level 24. Returns the API level of the device we're actually running on, or -1 on failure. The returned values correspond to the named constants in <android/api-level.h>
, and is equivalent to the Java Build.VERSION.SDK_INT
API.
See also android_get_application_target_sdk_version().
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-01-15 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-15 UTC."],[],[],null,["# API Levels\n==========\n\nDefines functions and constants for working with Android API levels.\n\nSummary\n-------\n\n| ### Functions ||\n|-------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [android_get_device_api_level](#group__apilevels_1ga79b134cadc2dfed84268e67fd9e2dfd6)`()` | `int` Returns the `targetSdkVersion` of the caller, or `__ANDROID_API_FUTURE__` if there is no known target SDK version (for code not running in the context of an app). |\n\nFunctions\n---------\n\n### android_get_device_api_level\n\nDeclared in `android/api-level.h` \n\n```scdoc\nint android_get_device_api_level()\n``` \nReturns the `targetSdkVersion` of the caller, or `__ANDROID_API_FUTURE__` if there is no known target SDK version (for code not running in the context of an app).\n\nThe returned values correspond to the named constants in `\u003c`[android/api-level.h](/ndk/reference/api-level/8h#api-level_8h)`\u003e`, and is equivalent to the AndroidManifest.xml `targetSdkVersion`.\n\nSee also [android_get_device_api_level()](/ndk/reference/group/apilevels#group__apilevels_1ga79b134cadc2dfed84268e67fd9e2dfd6).\n\nAvailable since API level 24. Returns the API level of the device we're actually running on, or -1 on failure. The returned values correspond to the named constants in `\u003c`[android/api-level.h](/ndk/reference/api-level/8h#api-level_8h)`\u003e`, and is equivalent to the Java `Build.VERSION.SDK_INT` API.\n\nSee also android_get_application_target_sdk_version()."]]