简体   繁体   English

我想使用Java获取我的Android设备的Build Number,Android版本。 我使用以下代码:

[英]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.

相关问题 我想使用以下代码将字符串从android设备发送到java桌面应用程序im - i want to sent string from android device to java desktop application im using following code 我想将数据从PC传输到我正在使用以下代码的Android手机,但我无法获得工作目录 - i want to transfer data from pc to android phone for which i am using the following code, i am not able to get working directory 我是android Java的初学者。 谁能解释代码 - I am beginner in android Java. Can anyone explain the code 在我正在开发的程序中,我需要使用Java打开网络摄像头。 为此,我已经使用opencv进行了编码,但是以下异常弹出窗口 - In the program I am developing I need to open the webcam using java. for that i have coded using opencv but the following exception popups 我正在尝试使用Java更新oracle数据库中的密码。 难道我做错了什么? - I'm trying to update my password in oracle database using Java. Am I doing something wrong? 尝试使用Java查找GCD。 我在逻辑上坚持做某些事情 - Trying to find the GCD using java. I am stuck on some things with my do while logic 我正在尝试使用Java获取网站的内容。 但是出现pxip错误 - I am trying to get contents of a site using java. but getting pxip error 我对android和Java非常陌生。 我想从一个类到另一个类获取字符串数组 - I,m very new to android and Java. I want to get a string array from one class to another class 将元素绑定到代码后,为什么我的代码总是收到空指针异常? 我在Android Studio中使用Java - Why is my code always receiving a null pointer exception when I have binded the element in to it? I am using Java in Android Studio 我正在使用 Java 制作工资单。 如果我的数学公式看起来是正确的,为什么我会得到错误的净工资? - I'm making a payroll using Java. Why am I getting the wrong net pay if my mathematical formulas seem correct?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM