Retrieving Android API version programmatically

前端 未结 11 1885
长情又很酷
长情又很酷 2020-11-22 04:54

Is there any way to get the API version that the phone is currently running?

11条回答
  •  情深已故
    2020-11-22 05:28

    Very easy:

       String manufacturer = Build.MANUFACTURER;
       String model = Build.MODEL;
       int version = Build.VERSION.SDK_INT;
       String versionRelease = Build.VERSION.RELEASE;
    
    Log.e("MyActivity", "manufacturer " + manufacturer
                + " \n model " + model
                + " \n version " + version
                + " \n versionRelease " + versionRelease
        );
    

    Output:

    E/MyActivity:   manufacturer ManufacturerX
                    model SM-T310 
                    version 19 
                    versionRelease 4.4.2
    

提交回复
热议问题