摘要:判斷device的android版本
查詢device內android版本:
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Log.d(TAG, "< 5.0 => " + Build.VERSION.SDK_INT);
} else {
Log.d(TAG, "> 5.0 => " + Build.VERSION.SDK_INT);
}
Build.VERSION_CODES: 各版本常數
- BASE Constant Value: 1 (0x00000001) Android 1.0
- BASE_1_1 Constant Value: 2 (0x00000002) Android 1.1
- CUPCAKE Constant Value: 3 (0x00000003) Android 1.5
- DONUT Constant Value: 4 (0x00000004) Android 1.6
- ECLAIR Constant Value: 5 (0x00000005) Android 2.0
- ECLAIR_0_1 Constant Value: 6 (0x00000006) Android 2.0.1
- ECLAIR_MR1 Constant Value: 7 (0x00000007) Android 2.1
- FROYO Constant Value: 8 (0x00000008) Android 2.2
- GINGERBREAD Constant Value: 9 (0x00000009) Android 2.3
- GINGERBREAD_MR1 Constant Value: 10 (0x0000000a) Android 2.3.3
- HONEYCOMB Constant Value: 11 (0x0000000b) Android 3.0
- HONEYCOMB_MR1 Constant Value: 12 (0x0000000c) Android 3.1
- HONEYCOMB_MR2 Constant Value: 13 (0x0000000d) Android 3.2
- ICE_CREAM_SANDWICH Constant Value: 15 (0x0000000f) Android 4.0
- JELLY_BEAN Constant Value: 16 (0x00000010) Android 4.0.3
- JELLY_BEAN_MR1 Constant Value: 17 (0x00000011) Android 4.1
- JELLY_BEAN_MR2 Constant Value: 18 (0x00000012) Android 4.2
- KITKAT Constant Value: 19 (0x00000013) Android 4.3
- KITKAT_WATCH Constant Value: 20 (0x00000014) Android 4.4
- LOLLIPOP Constant Value: 21 (0x00000015) Android 5.0
- LOLLIPOP_MR1 Constant Value: 22 (0x00000016) Android 5.1