public class SdkVersionInfo
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
HIGHEST_KNOWN_API
The highest known API level.
|
static int |
HIGHEST_KNOWN_API_TV
The highest known API level for Android TV.
|
static int |
HIGHEST_KNOWN_API_WEAR
The highest known API level for Wearables.
|
static int |
HIGHEST_KNOWN_STABLE_API
Like
HIGHEST_KNOWN_API but does not include preview platforms |
static int |
LOWEST_ACTIVE_API
The lowest active API level in the ecosystem.
|
static int |
LOWEST_ACTIVE_API_TV
The lowest active api for TV.
|
static int |
LOWEST_ACTIVE_API_WEAR
The lowest active api for wearables.
|
static int |
LOWEST_COMPILE_SDK_VERSION
The lowest api level we can accept for compileSdkVersion for
for a new project.
|
Constructor and Description |
---|
SdkVersionInfo() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
camelCaseToUnderlines(java.lang.String string)
Converts a CamelCase word into an underlined_word
|
static java.lang.String |
getAndroidName(int api)
Returns the Android version and code name of the given API level
The highest number (inclusive) that is supported
is
HIGHEST_KNOWN_API . |
static java.lang.String |
getAndroidVersionCodeName(com.android.sdklib.AndroidVersion version)
Returns the codename for a given
AndroidVersion 's API level. |
static int |
getApiByBuildCode(java.lang.String buildCode,
boolean recognizeUnknowns)
Returns the API level of the given build code (e.g.
|
static int |
getApiByPreviewName(java.lang.String previewName,
boolean recognizeUnknowns)
Returns the API level of the given preview code name (e.g.
|
static java.lang.String |
getBuildCode(int api)
Returns the applicable build code (for
android.os.Build.VERSION_CODES ) for the corresponding API level,
or null if it's unknown. |
static java.lang.String |
getCodeName(int api) |
static com.android.sdklib.AndroidVersion |
getVersion(java.lang.String apiOrPreviewName,
IAndroidTarget[] targets)
Returns the
AndroidVersion for a given version string, which is typically an API
level number, but can also be a codename for a preview platform. |
static java.lang.String |
getVersionString(int api) |
static java.lang.String |
underlinesToCamelCase(java.lang.String string)
Converts an underlined_word into a CamelCase word
|
public static final int HIGHEST_KNOWN_API
public static final int HIGHEST_KNOWN_STABLE_API
HIGHEST_KNOWN_API
but does not include preview platformspublic static final int LOWEST_ACTIVE_API
public static final int HIGHEST_KNOWN_API_WEAR
public static final int LOWEST_ACTIVE_API_WEAR
public static final int HIGHEST_KNOWN_API_TV
public static final int LOWEST_ACTIVE_API_TV
public static final int LOWEST_COMPILE_SDK_VERSION
@NonNull public static java.lang.String getAndroidName(int api)
HIGHEST_KNOWN_API
.api
- the api level@Nullable public static java.lang.String getVersionString(int api)
@Nullable public static java.lang.String getCodeName(int api)
@Nullable public static java.lang.String getBuildCode(int api)
android.os.Build.VERSION_CODES
) for the corresponding API level,
or null if it's unknown. The highest number (inclusive) that is supported
is HIGHEST_KNOWN_API
.api
- the API level to look up a version code forpublic static int getApiByBuildCode(@NonNull java.lang.String buildCode, boolean recognizeUnknowns)
buildCode
- the build code name (not case sensitive)recognizeUnknowns
- if true, treat an unrecognized code name as a newly released
platform the tools are not yet aware of, and set its API level to
some higher number than all the currently known API versionsHIGHEST_KNOWN_API
plus one is returnedpublic static int getApiByPreviewName(@NonNull java.lang.String previewName, boolean recognizeUnknowns)
previewName
- the preview name (not case sensitive)recognizeUnknowns
- if true, treat an unrecognized code name as a newly released
platform the tools are not yet aware of, and set its API level to
some higher number than all the currently known API versionsHIGHEST_KNOWN_API
plus one is returned@NonNull public static java.lang.String camelCaseToUnderlines(@NonNull java.lang.String string)
string
- the CamelCase version of the word@NonNull public static java.lang.String underlinesToCamelCase(@NonNull java.lang.String string)
string
- the underlined word to convert@Nullable public static com.android.sdklib.AndroidVersion getVersion(@Nullable java.lang.String apiOrPreviewName, @Nullable IAndroidTarget[] targets)
AndroidVersion
for a given version string, which is typically an API
level number, but can also be a codename for a preview platform. Note: This should
not be used to look up version names for build codes; for that, use getApiByBuildCode(String, boolean)
. The primary difference between this method is that
getApiByBuildCode(String, boolean)
will return the final API number for a platform
(e.g. for "KITKAT" it will return 19) whereas this method will return the API number for the
codename as a preview platform (e.g. 18).apiOrPreviewName
- the version stringtargets
- an optional array of installed targets, if available. If the version
string corresponds to a code name, this is used to search for a
corresponding API level.AndroidVersion
, or null if the version could not be
determined (e.g. an empty or invalid API number or an unknown code name)@Nullable public static java.lang.String getAndroidVersionCodeName(@NonNull com.android.sdklib.AndroidVersion version)
AndroidVersion
's API level.