|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.sdklib.AndroidVersion
public final class AndroidVersion
Represents the version of a target or device.
A version is defined by an API level and an optional code name.null instead.)
getApiLevel()
and getCodename()
.
For generic UI display of the API version, getApiString()
is to be used.
Nested Class Summary | |
---|---|
static class |
AndroidVersion.AndroidVersionException
Thrown when an AndroidVersion object could not be created. |
Field Summary | |
---|---|
static AndroidVersion |
DEFAULT
The default AndroidVersion for minSdkVersion and targetSdkVersion if not specified |
Constructor Summary | |
---|---|
AndroidVersion(int apiLevel,
java.lang.String codename)
Creates an AndroidVersion with the given api level and codename. |
|
AndroidVersion(java.util.Properties properties)
Creates an AndroidVersion from Properties . |
|
AndroidVersion(java.util.Properties properties,
int defaultApiLevel,
java.lang.String defaultCodeName)
Creates an AndroidVersion from Properties , with default values if the
Properties object doesn't contain the expected values. |
|
AndroidVersion(java.lang.String apiOrCodename)
Creates an AndroidVersion from a string that may be an integer API
level or a string codename. |
Method Summary | |
---|---|
boolean |
canRun(AndroidVersion appVersion)
Checks whether a device running a version similar to the receiver can run a project compiled for the given version. |
int |
compareTo(AndroidVersion o)
Compares this object with the specified object for order. |
int |
compareTo(int apiLevel,
java.lang.String codename)
|
boolean |
equals(int apiLevel)
Returns true if the AndroidVersion is an API level equals to
apiLevel. |
boolean |
equals(java.lang.Object obj)
Compares the receiver with either an AndroidVersion object or a String
object. |
int |
getApiLevel()
Returns the api level as an integer. |
java.lang.String |
getApiString()
Returns a string representing the API level and/or the code name. |
java.lang.String |
getCodename()
Returns the version code name if applicable, null otherwise. |
int |
getFeatureLevel()
Returns the API level as an integer. |
int |
hashCode()
|
boolean |
isGreaterOrEqualThan(int api)
Compares this version with the specified API and returns true if this version is greater or equal than the requested API -- that is the current version is a suitable min-api-level for the argument API. |
boolean |
isPreview()
Returns whether or not the version is a preview version. |
void |
saveProperties(java.util.Properties props)
|
java.lang.String |
toString()
Returns a string with the API Level and optional codename. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final AndroidVersion DEFAULT
Constructor Detail |
---|
public AndroidVersion(int apiLevel, @Nullable java.lang.String codename)
AndroidVersion
with the given api level and codename.
Codename should be null for a release version, otherwise it's a preview codename.
public AndroidVersion(@Nullable java.util.Properties properties, int defaultApiLevel, @Nullable java.lang.String defaultCodeName)
AndroidVersion
from Properties
, with default values if the
Properties
object doesn't contain the expected values.
The Properties
is expected to have been filled with
saveProperties(Properties)
.
public AndroidVersion(@NonNull java.util.Properties properties) throws AndroidVersion.AndroidVersionException
AndroidVersion
from Properties
. The properties must contain
android version information, or an exception will be thrown.
AndroidVersion.AndroidVersionException
- if no Android version information have been foundsaveProperties(Properties)
public AndroidVersion(@NonNull java.lang.String apiOrCodename) throws AndroidVersion.AndroidVersionException
AndroidVersion
from a string that may be an integer API
level or a string codename.
Important: An important limitation of this method is that cannot possible
recreate the API level integer from a pure string codename. This is only OK to use
if the caller can guarantee that only getApiString()
will be used later.
Wrong things will happen if the caller then tries to resolve the numeric
getApiLevel()
.
apiOrCodename
- A non-null API integer or a codename in its "ALL_CAPS" format.
"REL" is notable not a valid codename.
AndroidVersion.AndroidVersionException
- if the input isn't a pure integer or doesn't look like
a valid string codename.Method Detail |
---|
public void saveProperties(@NonNull java.util.Properties props)
public int getApiLevel()
getCodename()
.
To display the API level in the UI, use getApiString()
, which will use the
codename if applicable.
getCodename()
,
getApiString()
public int getFeatureLevel()
getApiLevel()
in the sense that it is useful when you want
to check the presence of a given feature from an API, and we consider the feature
present in preview platforms as well.
@Nullable public java.lang.String getCodename()
@NonNull public java.lang.String getApiString()
public boolean isPreview()
public boolean canRun(@NonNull AndroidVersion appVersion)
IAndroidTarget.canRunOn(IAndroidTarget)
.
Nevertheless, when testing if an application can run on a device (where there is no
access to the list of optional libraries), this method can give a good indication of whether
there is a chance the application could run, or if there's a direct incompatibility.
public boolean equals(int apiLevel)
true
if the AndroidVersion is an API level equals to
apiLevel.
public boolean equals(java.lang.Object obj)
AndroidVersion
object or a String
object.
If obj is a String
, then the method will first check if it's a string
representation of a number, in which case it'll compare it to the api level. Otherwise, it'll
compare it against the code name.
For all other type of object give as parameter, this method will return
false
.
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
getApiString()
instead.
toString
in class java.lang.Object
public int compareTo(@NonNull AndroidVersion o)
compareTo
in interface java.lang.Comparable<AndroidVersion>
o
- the Object to be compared.
public int compareTo(int apiLevel, @Nullable java.lang.String codename)
public boolean isGreaterOrEqualThan(int api)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |