Getting device os version in Android programmatically

前端 未结 5 1733
长发绾君心
长发绾君心 2020-12-01 13:35

How can I get the current android device version (1.5, 1.6, 2.0, etc.) programmatically? i.e I have installed my apk on an Android 2.2 device. I need to get the device versi

5条回答
  •  醉梦人生
    2020-12-01 14:28

    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){
        // Do something for lollipop and above versions
    } else{
        // do something for phones running an SDK before lollipop
    }
    

    By this code we can execute separate code for Pre Lollipop devices.

提交回复
热议问题