小白 android build类 小结

在某些情况下需要我们获取设备信息 ,比如获取手机型号,手机版本等
我们可以利用 android.os.Build 类获取

官方文档地址

1 查看 继承关系

这里写图片描述

2个嵌套类(内部类)

1、Build.VERSION 各种版本的字符串

2、Build.VERSION_CODES 枚举当前已知的SDK版本代码

22个静态属性

1、BOARD 主板:The name of the underlying board, like “goldfish”.

2、BOOTLOADER 系统启动程序版本号:The system bootloader version number.

3、BRAND 系统定制商:The consumer-visible brand with which the product/hardware will be associated, if any.

4、CPU_ABI cpu架构集:The name of the instruction set (CPU type + ABI convention) of native code.

5、CPU_ABI2 cpu架构集2:The name of the second instruction set (CPU type + ABI convention) of native code.

6、DEVICE 设备参数:The name of the industrial design.

7、DISPLAY 显示屏参数:A build ID string meant for displaying to the user

8、FINGERPRINT 唯一识别码:A string that uniquely identifies this build.

9、HARDWARE 硬件名称:The name of the hardware (from the kernel command line or /proc).

10、HOST

11、ID 修订版本列表:Either a changelist number, or a label like “M4-rc20”.

12、MANUFACTURER 硬件制造商:The manufacturer of the product/hardware.

13、MODEL 手机型号:The end-user-visible name for the end product.

14、PRODUCT 整个产品的名称:The name of the overall product.

15、RADIO 无线电固件版本:The radio firmware version number. 在API14后已过时。使用 getRadioVersion()代替。

16、SERIAL 硬件序列号:A hardware serial number, if available.
17、SUPPORTED_32_BIT_ABIS 32位序列列表 : An ordered list of 32 bit ABIs supported by this device.

18、SUPPORTED_64_BIT_ABIS 64位序列列表: An ordered list of 64 bit ABIs supported by this device.

19、TAGS 标签:Comma-separated tags describing the build, like “unsigned,debug”.

20、TIME

21、TYPE 类型:The type of build, like “user” or “eng”.

22、USER

1个公共方法

public static String getRadioVersion();

日志信息 参考

这里写图片描述

补充 几个
 /*
   * 获取 设备 uuid
   * GUID是一个128位长的数字,一般用16进制表示
   * UUID是1.5中新增的一个类,在java.util下,用它可以产生一个号称全球唯一的ID
   * 550E8400-E29B-11D4-A716-446655440000
   * */
    public static String getuuid() {
        if (uuid == null) {
            String s = UUID.randomUUID().toString();
            uuid = s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24);
        }
        return uuid;

    }
 /*
    * 获取 设备ID
    * */
    public static String getDevideId(Context context) {
        if (devideId == null) {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            devideId = tm.getDeviceId();
        }
        return devideId;

    }
/**
     * 获取ip地址
     *
     * @return
     */
    public static String getHostIP() {
        if (hostIp == null) {
            try {
                Enumeration nis = NetworkInterface.getNetworkInterfaces();
                InetAddress ia = null;
                while (nis.hasMoreElements()) {
                    NetworkInterface ni = (NetworkInterface) nis.nextElement();
                    Enumeration<InetAddress> ias = ni.getInetAddresses();
                    while (ias.hasMoreElements()) {
                        ia = ias.nextElement();
                        if (ia instanceof Inet6Address) {
                            continue;// skip ipv6
                        }
                        String ip = ia.getHostAddress();
                        if (!"127.0.0.1".equals(ip)) {
                            hostIp = ia.getHostAddress();
                            break;
                        }
                    }
                }
            } catch (SocketException e) {
                e.printStackTrace();
            }
        }
        return hostIp;

    }
/*
    * 获取 设备ID
    * */
    public static String getDevideId(Context context) {
        if (devideId == null) {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            devideId = tm.getDeviceId();
        }
        return devideId;

    }

以前很少写文章,也不知道怎么写好,希望做些有意义的事情,不要让自己再坠落了,希望能和大家一起进步。如有错误,希望指出。谢谢!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值