Detect Android N version code

后端 未结 4 1782
既然无缘
既然无缘 2021-02-06 03:12

Is it possible to detect if an user is running Android N?

I have a Nexus 6 with the Android N Developer Preview. If I try to get the build version with Build.VERSI

4条回答
  •  余生分开走
    2021-02-06 03:38

    I would recommend using Integer value for checking Android version rather than String

    public boolean isAndroidN() {
            return Build.VERSION.SDK_INT == Build.VERSION_CODES.N;
        }
    

    Just remember it's necessary to have compileSdkVersion to 24 or higher in manifests.xml:

    compileSdkVersion 24
    

提交回复
热议问题