我可以使用Android版code常量与旧的Android运行时?例如,
Can I use Android version code constants with older Android runtimes? For instance,
if (android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.HONEYCOMB) ...
能不崩溃上运行的蜂窝前,Android操作系统的旧设备,这个运行时,这个常数被首次定义?假设我们有足够新的SDK编译它?
would this run without crash on old devices running Android operating system before HONEYCOMB when this constant has been first defined? Assuming we compile it with recent enough SDK?
是的,这会工作。
这样做的原因是, android.os.Build.VERSION_ codeS.HONEYCOMB
是 INT
。 android.os.Build.VERSION_ codeS.HONEYCOMB
只是一个别名(即 INT
等于 11
)的 11
,因为可以在IDE中可以看出,比如Eclipse:
The reason for this is that android.os.Build.VERSION_CODES.HONEYCOMB
is an int
. android.os.Build.VERSION_CODES.HONEYCOMB
is just an alias (the int
equals 11
) for 11
, as can be seen in an IDE such as Eclipse:
int android.os.Build.VERSION_CODES.HONEYCOMB = 11 [0xb]
因此,这将工作,因为它只会检查 android.os.Build.VERSION.SDK_INT
大于或等于11。