[英]I want to get Build Number, Android Version of my Android device using Java. I am using the following code:
public class Device {
public static void main(String[] args) {
//buildNum = Build.DISPLAY;
System.out.println("Build Number: " + android.os.Build.DISPLAY);
System.out.println("Model: " + android.os.Build.MODEL);
System.out.println("Build Version: " + android.os.Build.VERSION.RELEASE);
}
}
It gives me output as: 它给我的输出为:
Build Number: null 内部编号:null
Model: null 型号:null
Build Version: null 构建版本:null
Can anybody point out where I am ding the mistake? 任何人都可以指出我错在哪里吗?
The problem might be that you're querying these values from a main method. 问题可能是您从main方法查询这些值。
Therefore, it might not be running on an actual Android device. 因此,它可能无法在实际的Android设备上运行。 Then of course there'll be no correct values.
那么当然没有正确的价值观。
You'll need to access these values from an Android device or it will have no Version number etc.. 您需要从Android设备访问这些值,否则它将没有版本号等。
I doubt the code you posted runs/compiles as you posted it. 我怀疑你发布的代码在发布时运行/编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.