难道Android版本code常量与旧版本的工作?常量、旧版本、版本、工作

2023-09-05 00:21:26 作者:风雨踏梦行

我可以使用Android版code常量与旧的Andr​​oid运行时?例如,

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。

 
精彩推荐
图片推荐