This is a code I extracted from active project called HideBar. This code logs the AndroidVersion and returns AndroidVersion.
public enum AndroidVersion {
HC, ICS, JB, UNKNOWN
};
public AndroidVersion getAndroidVersion() {
Log.v(LOG_TAG, "getAndroidVersion called");
int sdk = android.os.Build.VERSION.SDK_INT;
if (11 <= sdk && sdk <= 13) {
Log.v(LOG_TAG, "We are running on HoneyComb");
return AndroidVersion.HC;
} else if (14 <= sdk && sdk <= 15) {
Log.v(LOG_TAG, "We are running on IceCreamSandwich");
return AndroidVersion.ICS;
} else if (16 == sdk) {
Log.v(LOG_TAG, "We are running on JellyBean");
return AndroidVersion.JB;
} else {
Log.v(LOG_TAG, "We don't know what we are running on");
return AndroidVersion.UNKNOWN;
}
}
Comments
Post a Comment