如何以编程方式确定最新的 Android 版本?

How can I determine the latest Android version programmatically?

我想在我的应用程序中检查设备是否运行最新版本的 Android。

有办法吗?

是的,我可以一年更新一次我的应用程序,但我宁愿从技术上解决这个问题。

尝试添加并检查

String androidOS = Build.VERSION.RELEASE;

下面的方法也行得通

int version = Build.VERSION.SDK_INT;
String company = Build.MANUFACTURER;
String model = Build.MODEL;
String release = Build.VERSION.RELEASE;

Log.e("TAG", "company " + company)
Log.e("TAG", "model " + model)
Log.e("TAG", "version " + version)
Log.e("TAG", "release " + release)

来自 Gabe Sechan 的评论:

Unless you want to create a webservice that publishes the version number of the latest Android and query it, no. There's no way to no without a service publishing it what the latest Android is. And even if you did, nobody ships stock Android- they all cherry pick additions and all use different minor build releases. So you could at most know if it was the right major version